2010-11-08 177 views
1

我希望我的應用程序在驅動器C的特定文件夾(如C:\ myFolder \ abc.mdb)中查找文件,如果發現只是提供一條消息,請將該文件夾放入驅動器C: \然後複製文件。製作文件夾和複製文件

如何做到這一點? 感謝 Furqan

回答

1

你可以使用在System.IOFileDirectory,並Path對象,如下圖所示:

Imports System.IO 

... 

Dim path As String = "C:\myFolder\abc.mdb" 

If File.Exists(path) Then 
    'TODO write code to create message' 
Else 
    Dim folder As String = Path.GetDirectoryName(path) 
    If Not Directory.Exists(folder) then 
     Directory.CreateDirectory(folder) 
    End If 
    'TODO code to copy file from current location to the newly created directory path' 
    'i.e. File.Copy(FileToCopy, NewCopy)' 
End If 
+0

fileCopy是 – 2010-11-09 11:14:48

+0

非常感謝。 FileCopy是獲取文件的路徑? – 2010-11-09 11:15:16

+0

如何指定源路徑和目標路徑? – 2010-11-09 11:16:03