|
-
Oct 4th, 2012, 04:41 AM
#1
Thread Starter
Fanatic Member
Copy selected file (CommonDialog) to another folder?
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
-
Oct 4th, 2012, 05:01 AM
#2
Lively Member
Re: Copy selected file (CommonDialog) to another folder?
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.
-
Oct 4th, 2012, 05:02 AM
#3
Re: Copy selected file (CommonDialog) to another folder?
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
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 4th, 2012, 08:27 AM
#4
Re: Copy selected file (CommonDialog) to another folder?
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
-
Oct 4th, 2012, 08:38 AM
#5
Re: Copy selected file (CommonDialog) to another folder?
Or he could use the SHFileoperations-API or the CopyFileEx-API if he wants to show the Copy-Progress (usually only with big files)
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Oct 4th, 2012, 09:16 AM
#6
Thread Starter
Fanatic Member
Re: Copy selected file (CommonDialog) to another folder?
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
-
Oct 4th, 2012, 09:29 AM
#7
Re: Copy selected file (CommonDialog) to another folder?
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
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|