|
-
Oct 4th, 2000, 01:07 PM
#1
Thread Starter
Member
Hello everyone,
I was wondering if anyone can show me how to create a new folder and copy an existing file into the new folder using vb code. Basically, I want the function to create a new folder called "Test" in "C:\project" and copy a file called "Textfile.txt" into "C:\project\Textfile". Thank you!
Marci Sarwan ([email protected])
P.S. I would really appreciate it if you can please provide
some sample code along with the explanation. Thanks!
-
Oct 4th, 2000, 01:19 PM
#2
Here you go:
Code:
If Dir("C:\project\Test", vbDirectory) <> "" Then
MkDir "C:\project\Test"
FileCopy "Textfile.txt", "C:\project\Textfile"
End If
-
Oct 4th, 2000, 01:35 PM
#3
Thread Starter
Member
Hello Matthew,
how do I copy the Textfile.txt into the desired directory as a different name. Can I do it like this?
FileCopy "Textfile.txt", "C:\project\Another_Name.txt"
Thanks!
Marci
-
Oct 4th, 2000, 03:35 PM
#4
-
Oct 4th, 2000, 03:44 PM
#5
Hyperactive Member
And Also...
You can also do this:
Code:
Dim Name As String
Dim Name2 As String
Name2 = InputBox("Enter a folder:","Copy To...")
Name = "C:\Project\" & Name2
If Dir(Name,vbDirectory) <> "" Then
MkDir name
FileCopy "Textfile.txt", Name
End If
Nice one, isn't it?
[Edited by Asaf_99 on 10-04-2000 at 04:48 PM]
-
Oct 4th, 2000, 08:28 PM
#6
Asaf_99, can you use Name? Name is to rename a file. I think you have to use a different variable. I may be wrong though .
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
|