vb: how to check directory / folder existence and create folder, copy files?
Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
|
This site provides users with the information about vb, visual basic, vb6, how to check directory existence, how to check folder existence, how to create folder, how to copy files, use FileCopy function, use MkDir function, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
How to check directory exsitence and create folder, copy files?
The following is the code to check directory existence, create folder, copy files:
Private Sub Command1_Click()
If (DirExists("novel")) Then
'filecopy [fromfile],[tofile]
FileCopy "c:\novel_sav\test.txt", "c:\novel\test.txt"
else
MkDir(App.Path & "\NovelSave\novel\") 'create directory
End If
End Sub
Function DirExists(DirName As String) As Boolean
On Error GoTo ErrorHandler
'test the directory attribute
DirExists = GetAttr(DirName) And vbDirectory
ErrorHandler:
'if an error occurs, this function returns False
End Function
|