简体   繁体   中英

C# ClickOnce Deployment Mapping Back to My Desktop Drive

I created a WinForms application that includes code to find the user's desktop and perform 3 tasks: 1. Create a folder 2. Read a .csv file 3. Output some data to a .csv file on the desktop.

I'm using the code below to find the user's desktop

    string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

I used the ClickOnce deployment to install the program to our network drive. The program installs successfully, but Whenever I have someone attempt to run the program from their terminal, they get an error message that states "The directory name is invalid" and it references my desktop and not the user's.

How should I change my code or the deployment method so it references the user's desktop?

If directory invalid try creating it Try with this code

 string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); 
 string extension = ".log"; filePath += @"\Error Log\" + extension;
  if (!Directory.Exists(filePath)) { 
 Directory.CreateDirectory(filePath); 
 }

我对代码进行了以下更改,并根据需要进行了更改:

string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM