I want my C# winforms program to copy it self to system32
I've made a C开发者_如何学运维# windows forms application and want this application to copy itself (the file of the program) to the system32 of the current system. I want such function:
function copyProg() {
//copy the program to the system32 of current windows version...
//return the new url
}
This is a "bad idea" and "frowned upon". A cleaner and more accepted practice is to create an environment variable that points to your applications startup directory.
string localPath = Application.StartupPath;
Environment.SetEnvironmentVariable("EXAMPLE", localPath);
精彩评论