Results 1 to 9 of 9

Thread: [RESOLVED] [2005] Putting folde contents names into a text box?r

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Resolved [RESOLVED] [2005] Putting folde contents names into a text box?r

    hey, im writing a program that has a button which opens up a folder browser dialog, then the user chooses a folder and the names of the files in that folder are put into a text box, i dont need the file extension to be printed there, just the file names and extensions.

    does anyone have any idea on how i will be able to do this?

    thanks in advanced

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] Putting folde contents names into a text box?r

    You don't need the file extension, just the file names and extensions? That doesn't make much sense to me.
    My usual boring signature: Nothing

  3. #3
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: [2005] Putting folde contents names into a text box?r

    Code:
                Dim di As New IO.DirectoryInfo(FolderDialog1.SelectedPath)
                Dim aryFi As IO.FileInfo() = di.GetFiles("*.*")
                Dim fi As IO.FileInfo
                For Each fi In aryFi
                   If TextBox1.MultiLine = True Then
                   TextBox1.Text = TextBox1.Text & vbCrlf & fi.Name.Replace(fi.Extension,"")
                   Else
                   TextBox1.Text = TextBox1.Text & " | " & fi.Name.Replace(fi.Extension,"")
                   End If
                Next
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Re: [2005] Putting folde contents names into a text box?r

    sorry lol i ment i didnt need file paths lol just file names and extensions

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Re: [2005] Putting folde contents names into a text box?r

    and ty for the code, but VS seems to have a problem with it when i click the addfile button the program crashes and;

    "di As New IO.DirectoryInfo(dlgBrowse.SelectedPath)"

    is highlighted with the exception;

    "path is not of a legal form"

    any ideas on that?

    thanks all help is appreciated

  6. #6
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: [2005] Putting folde contents names into a text box?r

    What have you got the initial directory set as?
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Re: [2005] Putting folde contents names into a text box?r

    vb Code:
    1. Imports System.IO
    2. Public Class frmBrowser
    3.     Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
    4.         Dim di As New IO.DirectoryInfo(dlgBrowse.SelectedPath)
    5.         Dim aryFi As IO.FileInfo() = di.GetFiles("*.*")
    6.         Dim fi As IO.FileInfo
    7.         For Each fi In aryFi
    8.             If txtFolders.Multiline = True Then
    9.                 txtFolders.Text = txtFolders.Text & vbCrLf & fi.Name.Replace(fi.Extension, "")
    10.             Else
    11.                 txtFolders.Text = txtFolders.Text & " | " & fi.Name.Replace(fi.Extension, "")
    12.             End If
    13.         Next
    14.     End Sub
    15. End Class

    thats wot i got completely lol

  8. #8

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Re: [2005] Putting folde contents names into a text box?r

    i think i found the problem

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    15

    Re: [2005] Putting folde contents names into a text box?r

    i managed to solve it lol im a dumbass i hadnt launched the dialog so what was the selected path supposed to be, no wonder the error lol, thanks for all the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width