2010-04-26 67 views
4

這是我設置爲掃描文件的目錄代碼:Directory.GetFiles返回整個路徑,我只想要文件名?

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 

有沒有辦法做到這一點,而無需通過所有的數組項剪掉解析路徑?

謝謝。

回答

12
string filename= System.IO.Path.GetFileName(fullpathname); 
相關問題