VS调试模式和直接运行exe的结果不同
「已注销」 2012-08-21 03:26:18 private void button4_Click(object sender, EventArgs e)
{
string desktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonDesktopDirectory);
string luhExePath = @"D:\Program Files\TTPlayer\TTPlayer.exe";
WshShell shell = new WshShell();
IWshShortcut luhDesktopCut = (IWshShortcut)shell.CreateShortcut(string.Format("{0}/{1}.lnk", desktopPath, "HRM"));
luhDesktopCut.TargetPath = luhExePath;
luhDesktopCut.Description = "HRM系统";
luhDesktopCut.WorkingDirectory = luhExePath;//程序所在文件夹,在快捷方式图标点击右键可以看到此属性
luhDesktopCut.Hotkey = "CTRL+SHIFT+H";//热键
luhDesktopCut.WindowStyle = 1;
FileInfo file = new FileInfo(string.Format("{0}/{1}.lnk", desktopPath, "HRM"));
if (file.Exists) {
file.Delete();
}
try {
MessageBox.Show(file.FullName);
luhDesktopCut.Save();
}
catch (Exception ew) {
MessageBox.Show(ew.Message);
}
}
这是我的一个Button控件的点击事件,主要就是在桌面创建一个快捷方式,问题是:如果直接F5运行,可以创建,一切OK,但如果运行生成好的exe文件,就不能创建???Why? 应该是权限问题,怎么解决呢?