Justin-Credible
07-01-2004, 01:02 PM
CopyFile CommonDialog1.filename, App.Path & "\temp\", True
Whats wrong with this code? I need to copy the file in the commondialog to the app.path\temp folder, but I need to keep the same name as the file as in the commondialog.filename.
Is there a way to copy a file to a folder without specifying the filename, just using the same filename instead?
Having a brain freeze here... :confused:
CopyFile CommonDialog1.filename, App.Path & "\temp\", True
Did you mean FileCopy?
reboot
07-01-2004, 01:31 PM
CopyFile is a Windows API and would have to be declared. If you're trying to use the native VB function, it's as Jigo said.
Chris J Locke
07-01-2004, 04:53 PM
I *think* VB is getting confused and thinks you want to copy a file as a directory, instead of into one...
Add the filename to the directory, for example:
CopyFile "c:\test\myfile.ext", App.Path & "\temp\myfile.ext", True
From a full filename, its not too hard to break it up and work out what just the file is called.
I've a funny feeling thats whats going on though...
So, some sample code...
ls_fullFilename = commondialog1.filename
ls_file = Right$(ls_fullFilename, InStrRev(ls_fullFilename, "\"))
CopyFile CommonDialog1.filename, App.Path & "\temp\" & ls_file, True
Justin-Credible
07-01-2004, 05:55 PM
Thanks guys. Chris' example is what I'm going for; a way to find the file name (just the filename, not the entire path) from the CommonDialog.FileName.
I've been messing with the sample code, but I haven't gotten it to work...
Justin-Credible
07-01-2004, 05:58 PM
Got it. Did a search on the forum and found the FileTitle property of CommonDialog returns the filename without the path.
Thanks for the help!