|
-
Apr 4th, 2007, 02:29 AM
#1
Thread Starter
Member
[RESOLVED] [2005] How to get list of files under selected folder ??
Hi!
I am required to acquire the filenames of all the bitmap (.bmp) files inside a folder which is selected by the user.
I am using the FolderBrowserDialog to recieve the path of the selected folder but i dont know how to get to the files inside the folder. I think that the filenames can be stored in an Array but i am not able to do it. Can anyone please me out..
Please gimme the code if you can.. thx
cheers
Abhilash
-
Apr 4th, 2007, 02:32 AM
#2
Re: [2005] How to get list of files under selected folder ??
-
Apr 4th, 2007, 02:38 AM
#3
Thread Starter
Member
Re: [2005] How to get list of files under selected folder ??
Hey
I dont know how to use that command.. i tried looking at the msdn library but nothing comes up.. can u tell me how to use IO.File.GetFiles
cheers
Abhilash
-
Apr 4th, 2007, 02:44 AM
#4
Re: [2005] How to get list of files under selected folder ??
Put file.getfiles into the MSDN library index and it will come up. If you include the leading IO it won't, but you should include the IO namespace when you use it in code.
-
Apr 4th, 2007, 04:52 AM
#5
Registered User
Re: [2005] How to get list of files under selected folder ??
vb Code:
'This code will work to get all the file names in your directory
Dim path As String = "E:\pictures"
Dim file_name() As String = {}
Dim i As Integer = 0
Dim fld As New System.IO.DirectoryInfo(path)
Dim fil As System.IO.FileInfo
ReDim file_name(fld.GetFiles("*.bmp").Length - 1)
For Each fil In fld.GetFiles("*.bmp")
file_name(i) = fil.Name
i = i + 1
Next
-
Apr 4th, 2007, 10:06 PM
#6
Thread Starter
Member
Re: [2005] How to get list of files under selected folder ??
Hey Ravi!
The code you sent works perfect.. is thr a way to remove the extension name and get only the filename.. i need it to compare with another record.. so i need only the filename without extension... please Advise
cheers
Abhilash
-
Apr 4th, 2007, 10:39 PM
#7
Re: [2005] How to get list of files under selected folder ??
vb Code:
For Each filePath As String In IO.Directory.GetFiles("folder path here", "*.bmp")
MessageBox.Show(IO.Path.GetFileNameWithoutExtension(filePath)
Next filePath
-
Apr 5th, 2007, 01:30 AM
#8
Thread Starter
Member
Re: [2005] How to get list of files under selected folder ??
Hey..
your method works fine... thx a lot
cheers
Abhilash
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|