简体   繁体   English

我希望我的C#winforms程序将其自身复制到system32

[英]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. 我已经制作了一个C#Windows窗体应用程序,并希望该应用程序将自身(程序文件)复制到当前系统的system32中。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM