How can i get all files without file extension into an array. I will supply the folder path. Is this possible using Directory.GetFiles() or DirectoryInfo.GetFiles()?? Is there any alternative way?
I am using ASP.NET C#.
How can i get all files without file extension into an array. I will supply the folder path. Is this possible using Directory.GetFiles() or DirectoryInfo.GetFiles()?? Is there any alternative way?
I am using ASP.NET C#.
I would guess:
string[] files = Directory.GetFiles(dir,"*.")
(now verified; that works fine) - note that you may need to use Server.MapPath
to switch between relative site paths and physical disk paths, and that the results of Directory.GetFiles
are full paths.
If you need to get just the name part of all files in a folder (even those with extensions):
string[] files = Directory.GetFiles(dir,"*.*")
.Select(n => Path.GetFileNameWithoutExtension(n))
.ToArray();