在C#中,最简单的方法是,如果我在VS Windows Forms应用程序中单击按钮,则将自己(exe程序)从c:\\data
剪切并粘贴到c:\\data2
吗?
There is no way an executing application can move itself.
What you could do is:
Suppose you have:
A - Executing Application.
B - Spawned Application.
Now:
A
is executing. A
creates another app called B
. A
shuts down. B
moves A
from Data
to Data2
. B
starts A
from new location. B
shuts down. You can File.Copy to transfer the file from one folder to another. For example...
File.Copy("C:\Data\MyProgram.exe", "C:\Data2\MyProgram.exe"
Taz suggested that the file won't copy as it's executing and that's something to watch out for, but I've been able to copy running programs before.
There is no way. I don't think it is possible as the file is executing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.