Copying A File

Sharoon

New member
Local time
Today, 14:08
Joined
Nov 30, 2003
Messages
8
Coping File

Hi
I would like to copy file to a new folder in the C drive and rename it
ex.
c:/Folder/file.txt
Where Folder is not created before, I would like to create it then copy that file to that folder.
 
You will need to use the Dir Function to test if the directory exists and use the MkDir Statement to create the directory if it does not. Then you can use the FileCopy Statement to copy [rename] the file. Check the help files for these functions for more info and examples...

Dir Function
MkDir Statement
FileCopy Statement

HTH
 
Thank u for u help

I would like to check if directory exists before creating it
do u have idea how to code it?
 
Code:
	Dim mydir As String

	mydir = Dir("c:\mydata", vbDirectory)
    
	If Len(mydir) <> 0 Then
		MsgBox "This directory exists."
	Else
		MsgBox "This directory doesn't exist."
	End If

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom