Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make the exectuable copy itself somewhere else

Status
Not open for further replies.

Bluethunder1

Programmer
May 24, 2005
1
US
It all works, except when I try to do the copy it says: "Cannot access the file because it's already being used" Well, the program already using it is, naturally its self... Do you guys know a way to get around this? Thanks!

 
The following lines are working.
The console app copies itself onto C:\temp directory.
Code:
static void Main(string[] args)
      {
	string src = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
        string dest = "C:\\temp\\" + System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;
		    System.IO.File.Copy(src,dest);
	}
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top