.NET获取系统特殊文件夹路径

      计算机与编程 2007-11-19 11:13:00

string StartupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
System.IO.File.Copy("应用程序路径(包括程序名)", StartupPath + "执行程序文件名称", true);

//获得文件的当前路径
string dir = Directory.GetCurrentDirectory();
//获取可执行文件的全部路径
string exeDir = dir + "WindowsApplication1.exe";

//获取Run键
RegistryKey   key1=Registry.LocalMachine;
RegistryKey   key2=key1.CreateSubKey("SOFTWARE");
RegistryKey   key3=key2.CreateSubKey("Microsoft");
RegistryKey   key4=key3.CreateSubKey("Windows");
RegistryKey   key5=key4.CreateSubKey("CurrentVersion");
RegistryKey   key6=key5.CreateSubKey("Run");
//在Run键中写入一个新的键值
key6.SetValue("myForm",exeDir);
key6.Close();
     
//如果要取消的话就将key6.SetValue("myForm",exeDir);改成
//key6.SetValue("myForm",false);

标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}