开发者

What's the fast way to get the file name?

myVar = "D:\\mainfolder\\subf1\\开发者_开发知识库subf2\\subf3\\file.txt";

How can I get file.txt conveniently in .NET 2.0 with C#? What I know is split with \\ and try to get the last member.

Thanks.


string fileNameOnly = Path.GetFileName("D:\\mainfolder\\subf1\\subf2\\subf3\\file.txt");

should return file.txt

Linking Path's class documentation on MSDN. Has many other convenient methods.


System.IO.Path.GetFileName(myVar);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜