Jump to content

How to copy a file from one folder to another that's in the same directory as the program? VB

snoopy6489

Hello i am wondering how would i copy a file that is in one folder to another in the same directory as the program in visual basic? Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

File.Copy

 

You should just have to specify the source path/filename, then the destination path/filename.

 

To reference a file from the current directory, just start with a '.' then the path to the file.

 

I.E.  "./subdirectory/filename.txt"

Link to comment
Share on other sites

Link to post
Share on other sites

File.Copy

 

You should just have to specify the source path/filename, then the destination path/filename.

 

To reference a file from the current directory, just start with a '.' then the path to the file.

 

I.E.  "./subdirectory/filename.txt"

I know that one i was wondering if its possible to do it and say it will always be with that program

Link to comment
Share on other sites

Link to post
Share on other sites

Ah, gotcha...  unsure of the best way on that one... sorry....

Link to comment
Share on other sites

Link to post
Share on other sites

I know that one i was wondering if its possible to do it and say it will always be with that program

 

What do you mean by this?

Link to comment
Share on other sites

Link to post
Share on other sites

What do you mean by this?

that the 2 folders will be in the same directory as the program

Link to comment
Share on other sites

Link to post
Share on other sites

that the 2 folders will be in the same directory as the program

 

Meaning this

MyProgram/MyProgram/Folder1MyProgram/Folder2

and you want to transfer a file from Folder1 to Folder2 (or vice versa)?

Link to comment
Share on other sites

Link to post
Share on other sites

If your are looking for folders of software you are making, try to use "App.Path" that will give you location where your Project1.exe is.

 

And for file copy use function:

FileCopy "C:\file.dat", "C:\Windows\fileCopy.dat"

 

Or if you want to make copy of .exe you are running:

FileCopy App.Path & "\" & App.EXEName, "C:\Windows\copy.exe"
Link to comment
Share on other sites

Link to post
Share on other sites

 

If your are looking for folders of software you are making, try to use "App.Path" that will give you location where your Project1.exe is.

 

And for file copy use function:

FileCopy "C:\file.dat", "C:\Windows\fileCopy.dat"

Or if you want to make copy of .exe you are running:

FileCopy App.Path & "\" & App.EXEName, "C:\Windows\copy.exe"

ok thank you!!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×