有时候为了让程序开机就启动,可以直接将程序复制到"启动"文件夹中.
代码:
string StartupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
//获得文件的当前路径
string dir = Directory.GetCurrentDirectory();
//获取可执行文件的全部路径
string exeDir = dir + "WindowsApplication1.exe";
System.IO.File.Copy(exeDir, StartupPath + "WindowsApplication1.exe", true);

本文介绍了一种让程序随系统启动而自动运行的方法。通过将程序复制到系统的启动文件夹中,并提供了具体的C#代码实现。此方法适用于希望简化程序启动步骤或确保程序始终在后台运行的应用场景。
3278

被折叠的 条评论
为什么被折叠?



