开发者

How can i get all files without file extension into an array

How can i get all files without file extension into an array. I will su开发者_运维百科pply 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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜