Console Application安装

时间:2015-08-22 10:47:36

标签: c# console-application

我创建了一个控制台应用程序。并安装在我的系统中,工作正常。但我的应用程序自动安装到路径C:\ Users \ DELL \ AppData \ Roaming \ Microsoft \ Windows \ Start Menu \ Programs \ Microsoft

我的问题是如何将文件夹名称Microsoft更改为其他? 请帮帮我

1 个答案:

答案 0 :(得分:0)

为什么不自己安装,而不是复制一些你不完全理解的代码。

将其添加到代码的开头。

string runningPath = Directory.GetCurrentDirectory() + @"/" + Process.GetCurrentProcess().ProcessName + ".exe";
string path = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\Microsoft\Windows\StartMenu\Programs\";
string pathWithFolder = path + @"<Your folder name here>/" + Process.GetCurrentProcess().ProcessName + ".exe";

if(!File.Exists(pathWithFolder))
    File.Copy(runningPath, pathWithFolder);

如果尚未执行此操作,则此代码会将应用程序安装到该文件夹​​中。

注意:在调试模式下不要运行此代码。