By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

how can i copy a text file and paste it in a specific path

P: 47
how can i copy a text file and paste it in a specific path by VB6 code

another question
how can i create afolder in a specific path by VB6

thank you
Feb 28 '08 #1
Share this Question
Share on Google+
7 Replies


debasisdas
Expert 5K+
P: 8,127
Try to use FileSystemObject.
Feb 28 '08 #2

jamesd0142
100+
P: 469
Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. fso.CopyFile "C:\Files\file.txt", "C:\Files1\file_copy.txt" 
  3.  
to create mayb something like fso.createdirectory?

I think this will do it.

James
Feb 28 '08 #3

debasisdas
Expert 5K+
P: 8,127
try using this

MkDir "d:\debasisdas"

for creating a directory.
Feb 28 '08 #4

debasisdas
Expert 5K+
P: 8,127
If you want to move the file to another location then try this

Expand|Select|Wrap|Line Numbers
  1. Dim FSO As FileSystemObject
  2. Set FSO = CreateObject("Scripting.FileSystemObject")
  3. FSO.MoveFile "E:\DEBASIS\VB\DATA1.TXT", "E:\DEBASIS\DATA1.TXT"
  4.  
  5. 'or try to use 
  6.  
  7. Dim FSO As FileSystemObject, FO As FileSystemObject
  8. Set FSO = CreateObject("Scripting.FileSystemObject")
  9. Set FO = FSO.GetFile("E:\DEBASIS\VB\DATA1.TXT")
  10. FO.Move "E:\DEBASIS\DATA1.TXT"
  11.  
Feb 28 '08 #5

P: 47
Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. fso.CopyFile "C:\Files\file.txt", "C:\Files1\file_copy.txt" 
  3.  
to create mayb something like fso.createdirectory?

I think this will do it.

James
this code cause this error
compile error
user-defined type not defined
Feb 28 '08 #6

P: 47
If you want to move the file to another location then try this

Expand|Select|Wrap|Line Numbers
  1. Dim FSO As FileSystemObject
  2. Set FSO = CreateObject("Scripting.FileSystemObject")
  3. FSO.MoveFile "E:\DEBASIS\VB\DATA1.TXT", "E:\DEBASIS\DATA1.TXT"
  4.  
  5. 'or try to use 
  6.  
  7. Dim FSO As FileSystemObject, FO As FileSystemObject
  8. Set FSO = CreateObject("Scripting.FileSystemObject")
  9. Set FO = FSO.GetFile("E:\DEBASIS\VB\DATA1.TXT")
  10. FO.Move "E:\DEBASIS\DATA1.TXT"
  11.  
this code cause this error
compile error
user-defined type not defined
Feb 28 '08 #7

Expert 5K+
P: 8,435
this code cause this error
compile error
user-defined type not defined
You need to add a reference to Microsoft Scripting Runtime to your project.
Feb 29 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.