You can post same content "" on google or bing, it gives you a lot of links. First search on google / bing, if you unable to find on it or confuse then post here.
string[] filePaths = Directory.GetFiles(@"c:\Downloads\"); //Get File List in chosen directory
foreach (string path in filePaths) //iterate the file list
{
FileInfo file = new FileInfo(path); //get individual file info
Response.Write(Path.GetFileName(file.FullName) + "<br>"); //output individual file name
}
None
0 Points
14 Posts
how to get all file name from folder in c#?
Jan 23, 2013 03:14 AM|ahujanisha16|LINK
how to get all file name from folder in c#?
Star
8111 Points
2102 Posts
Re: how to get all file name from folder in c#?
Jan 23, 2013 03:17 AM|chandrashekar|LINK
Hi
Refer the post below. Below method will retrieve the filenames from as specified path
http://www.csharp-examples.net/get-files-from-directory/
http://msdn.microsoft.com/en-us/library/07wt70x2.aspx
http://stackoverflow.com/questions/6817639/get-filenames-without-path-of-a-specific-directory
Please try the answer for the post and finally Don't forget to click “Mark as Answer” on the post that helped you.
Member
324 Points
116 Posts
Re: how to get all file name from folder in c#?
Jan 23, 2013 03:20 AM|saeed_saedvand|LINK
you can use foreach and Directory Class:
Saeed Saedvand
Contributor
3829 Points
1281 Posts
Re: how to get all file name from folder in c#?
Jan 23, 2013 03:21 AM|matifnadeem|LINK
Hi ahujanisha16,
Let me know if any query remains.
Cheers
Member
20 Points
6 Posts
Re: how to get all file name from folder in c#?
Jan 23, 2013 03:51 AM|shaiksameer|LINK
string[] Filepaths ;
Filepaths = Directory.GetFiles(paste ur directory Path here);
for file name:
string FileName;
FileName = GetFileName(paste ur FilePath here);
Contributor
2030 Points
582 Posts
Re: how to get all file name from folder in c#?
Jan 23, 2013 04:10 AM|Sujeet Saste|LINK
Use following code :
Here "files" is the folder name from where we are getting file names in the string array named "FileNames"
To get file name from that array list refer following link :
http://www.gigasters.com/post.aspx?postid=38
Feel free to ask if you have any query.
Do FEAR (Face Everything And Rise)
Please mark as Answer if my post helps you..!
Member
469 Points
889 Posts
Re: how to get all file name from folder in c#?
Feb 01, 2013 03:22 PM|rkeslar|LINK
Contributor
3829 Points
1281 Posts
Re: how to get all file name from folder in c#?
Feb 02, 2013 07:26 AM|matifnadeem|LINK
Hi ahujanisha16,
You can post same content "" on google or bing, it gives you a lot of links. First search on google / bing, if you unable to find on it or confuse then post here.
Cheers
Member
469 Points
889 Posts
Re: how to get all file name from folder in c#?
Feb 04, 2013 01:53 PM|rkeslar|LINK
ahujanisha16, did you find the answer you were looking for?
Member
130 Points
39 Posts
Re: how to get all file name from folder in c#?
Feb 04, 2013 10:10 PM|deeps6ix|LINK
Hope this helps out