2

Hey guys, I'm coding a C# program to "Install" itself on the PC and run at starup to manage some scheduled tasks I have. I already have most of it done, including prompting the user, adding to startup, and such. But I want to copy the EXE when they run it after download, to C:\Program Files\Company\Program.exe

Is there any easy way to get the filepath+exe of a C# program from within the program? I've tried some System.Environment methods, and GetModuleInfo(), but I think I may just be overlooking something.

Is there a better way to go about this?

1
  • That requires administator privileges on many systems. Many users no longer run as admin by default. Are you sure this is a good idea? Commented Sep 10, 2010 at 23:53

3 Answers 3

1
System.Reflection.Assembly.GetExecutingAssembly().CodeBase 
Sign up to request clarification or add additional context in comments.

Comments

1
System.Reflection.Assembly.GetExecutingAssembly().Location 

Comments

0

// Get and display the full name of the EXE assembly. string exeAssembly = Assembly.GetEntryAssembly().FullName; Console.WriteLine(exeAssembly);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.