Directory.GetFiles 返回整个路径,我只想要文件名?

发布于 2024-08-30 00:49:41 字数 445 浏览 5 评论 0原文

这是我设置的用于扫描文件目录的代码:

Dim fileArray() As String
fileArray = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory & "help\")

它成功获取了目录中的所有文件,但也获取了它们的绝对路径。例如, fileArray() 中的条目之一是:

F:\Project\Project\bin\x86\Debug\help\book_troubleshoot.html

我希望它只是:

book_troubleshoot.html

有没有办法在不解析所有数组条目以修剪路径的情况下执行此操作?

谢谢。

This is the code I have set up to scan a directory of files:

Dim fileArray() As String
fileArray = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory & "help\")

And it successfully gets all files in the directory, but it gets their absolute paths aswell. For example, one of the entries in fileArray() is:

F:\Project\Project\bin\x86\Debug\help\book_troubleshoot.html

And I want it to just be:

book_troubleshoot.html

Is there a way to do this without parsing through all the array entries to trim off the path?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晌融 2024-09-06 00:49:42
string filename= System.IO.Path.GetFileName(fullpathname);
string filename= System.IO.Path.GetFileName(fullpathname);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文