Hi guys is it possible that when a user selects a file from commondialog1 (Open) and press the command button it will copy the file and paste a copy of it into the folder C:\New
?
thanks
Jamie
Printable View
Hi guys is it possible that when a user selects a file from commondialog1 (Open) and press the command button it will copy the file and paste a copy of it into the folder C:\New
?
thanks
Jamie
Yes it is possible. After selecting a file from Open Commondialog1, save its name with full path to a text box. Now in command button use CopyFile method to copy file to a new folder C:\New. May use FileScriptObject for this.
You could do this:
vb Code:
Dim original As String, dest As String Private Sub Command1_Click() CommonDialog1.ShowOpen original = CommonDialog1.FileName End Sub Private Sub Command2_Click() CommonDialog1.ShowSave dest = CommonDialog1.FileName FileCopy original, dest End Sub
Yes if you want to copy the file use the FileCopy method shown in post #3, do not use the FSO
If you want to move a file then you would use the Name method
Code:Name OldFilename As NewFileName
Or he could use the SHFileoperations-API or the CopyFileEx-API if he wants to show the Copy-Progress (usually only with big files)
Hi guys, I'm getting a run time error '52' bad file name which then highlights -
dest = "\\server\Attachments\"
FileCopy Text1.Text, dest
any ideas?
thanks
You have to use an explicit filename including path for destination or in your variable
Code:txtSource.Text="C:\MySourceFolder\MyFile.txt"
txtDest.Text="\\Server\Attachments\MyDestFile.txt"
FileCopy txtSource.Text, txtDest.Text