我已经完成了使用ClickOnce安装的.NET C# WPF安装。 一切正常。 然后,我有以下代码,它是安装程序的一部分:
String destinationPath = System.Windows.Forms.Application.StartupPath + "\\" + fileName;
File.Copy(path, destinationPath, true);
this.DialogResult = true;
this.Close();
但我得到了这个错误:
System.UnauthorizedAccessException:拒绝访问路径C:\ user \ pc \ appdata \ local \ apps \ 2.0.......。
在System.IO.File.InternalCopy(String sourceFileName,String destFileName,Boolean overwrite,Boolean checkHost)处 at System.IO.File.Copy(String sourceFileName,String destFileName,Boolean overwrite)
这是权限错误还是我需要调整一些代码?
令我困惑的是为什么用户能够使用一键单击将程序安装到该目录而没有任何问题,但上传文件却无法工作?