c# 拷贝文件到"启动"文件夹中

有时候为了让程序开机就启动,可以直接将程序复制到"启动"文件夹中.

代码:

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++,c,C#)