Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > CopyFile...


Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2004, 01:02 PM
Justin-Credible's Avatar
Justin-Credible Justin-Credible is offline
Regular
 
Join Date: Dec 2003
Posts: 93
Default CopyFile...


Code:
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...
Reply With Quote
  #2  
Old 07-01-2004, 01:04 PM
Jigo's Avatar
Jigo Jigo is offline
Junior Contributor
 
Join Date: Mar 2004
Location: Manila, PHIL
Posts: 294
Default

Quote:
Originally Posted by Justin-Credible
Code:
[B]CopyFile[/B] CommonDialog1.filename, App.Path & "\temp\", True
Did you mean FileCopy?
Reply With Quote
  #3  
Old 07-01-2004, 01:31 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

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.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #4  
Old 07-01-2004, 04:53 PM
Chris J Locke Chris J Locke is offline
Contributor
 
Join Date: Mar 2002
Location: Essex, UK
Posts: 690
Default

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:
Code:
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...
Code:
ls_fullFilename = commondialog1.filename
ls_file = Right$(ls_fullFilename, InStrRev(ls_fullFilename, "\"))
CopyFile CommonDialog1.filename, App.Path & "\temp\" & ls_file, True

Last edited by Chris J Locke; 07-01-2004 at 04:58 PM.
Reply With Quote
  #5  
Old 07-01-2004, 05:55 PM
Justin-Credible's Avatar
Justin-Credible Justin-Credible is offline
Regular
 
Join Date: Dec 2003
Posts: 93
Default

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...
Reply With Quote
  #6  
Old 07-01-2004, 05:58 PM
Justin-Credible's Avatar
Justin-Credible Justin-Credible is offline
Regular
 
Join Date: Dec 2003
Posts: 93
Default

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!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->