5 Replies - 28572 Views - Last Post: 27 July 2009 - 10:42 PM Rate Topic: -----

#1 muddasir  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 114
  • Joined: 14-January 07

How to copy/paste files

Posted 22 March 2008 - 05:46 AM

i want to copy a file from fixed location like

d:\my project\abc.txt

to the folder user select like

e:\backup\abc.txt

now what is the code to copy and what is the code to paste files

if any body know some sample project as just there are many sample/snippert
availeable in this site please tell me i had searched a lot but get nothing useful .
have no idea about how to write these codes

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: How to copy/paste files

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to copy/paste files

Posted 22 March 2008 - 09:42 AM

You're going to want to use the FileSystemObject in VB6 for copying files.
Was This Post Helpful? 0
  • +
  • -

#3 muddasir  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 114
  • Joined: 14-January 07

Re: How to copy/paste files

Posted 22 March 2008 - 11:39 AM

did i had to add some reference in my project
becasue if i write

Quote

dim fso as filesystemobject

just as i cross "as" it
has to show me filesystemobject automatically but n
not showing it at all as shown if fig1

Attached Image

similary if i write fso. it has to show me the functions
it has to perfom but showing nothing see pic
Attached Image

so what wrong with it













View PostPsychoCoder, on 22 Mar, 2008 - 09:42 AM, said:

You're going to want to use the FileSystemObject in VB6 for copying files.

Was This Post Helpful? 0
  • +
  • -

#4 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4316
  • View blog
  • Posts: 12,096
  • Joined: 18-April 07

Re: How to copy/paste files

Posted 22 March 2008 - 11:49 AM

Yeah you have to add the Microsoft Scripting Runtime reference.

Go to Project >> References... >> Microsoft Scripting Runtime and check the box next to it.

Then you should be able to use the FileSystemObject.

Enjoy! :)
Was This Post Helpful? 0
  • +
  • -

#5 muddasir  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 114
  • Joined: 14-January 07

Re: How to copy/paste files

Posted 22 March 2008 - 11:38 PM

i want to copy a specific file and paste into another folder
i am using the following code

Quote

'' getting the required file to be copied
fso.GetFile "D:\Data\smeb_Data.MDF"

'' creating newfolder
If fso.FolderExists("H:\Backup") Then
Else
fso.CreateFolder "H:\Backup"
End If

''pasting the file
fso.CopyFile "H:\Backup\smeb_Data.MDF"
Exit Sub



when i run this code i get errror
"argument not optional "

what chages i have to made in it
any help

i also want to copy more than one files and it should be pasted with
out promting that file already exists
Was This Post Helpful? 1

#6 Sri_nalinda  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 27-July 09

Re: How to copy/paste files

Posted 27 July 2009 - 10:42 PM

'' getting the required file to be copied 
fso.GetFile "D:\Data\smeb_Data.MDF"
 
'' creating newfolder 
If fso.FolderExists("H:\Backup") Then
Else
fso.CreateFolder "H:\Backup"
End If
 
''pasting the file
'Syntax
'fso.CopyFile OriginalFilePath,Pasting File Path

fso.CopyFile "D:\Data\smeb_Data.MDF", "H:\Backup\smeb_Data.MDF"
Exit Sub



Note :
When you pasting your copied file you should notify copied file path and pasting file path.

** Edit ** :code:
Was This Post Helpful? 1

Page 1 of 1