Copy / Move files without specific path vb

0

I have a program whose function is to copy and paste files, I have used My.Computer.FileSystem.CopyFile () to do it, and if it works ...

 My.Computer.FileSystem.CopyFile(C:\ruta ejemplo\archivo1.txt, C:\ruta ejemplo 2\archivo1.txt)

The problem is that my program is going to be portable, and I do not know how to make it extract the "file 1" from the program files instead of a specific path (C: \ example path) ... I can indicate as? THANKS in advance

    
asked by e2vl13 03.01.2019 в 21:30
source

1 answer

2

If you do not know the specific route, you have 2 options to solve it.

1- My.Application.Info.DirectoryPath() (returns the path where the program is running, which by default would help you)

Example:

My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath() & archivo1.txt, My.Application.Info.DirectoryPath() & archivo2.txt)

2- In the .config of the program, you could add that when the program is initialized, the main path from where is executed (Example " C:\ ") , then there you would already have that data to put it as an example.

    
answered by 03.01.2019 / 21:49
source