'An exception occurred during a WebClient request" while using C# ASP.NET

后端 未结 6 1694
生来不讨喜
生来不讨喜 2021-02-05 04:20

So, I have built an auto update program to my program.

The code that is running in here is:

new WebClient().DownloadFile(\"XXXX\", checkingfolder.Select         


        
6条回答
  •  遇见更好的自我
    2021-02-05 04:44

    Beside other answers, beware that the same WebException might also occur if the client process does not have needed permission to create output file.

    I would suggest you to take the following strategy:

    1. Download file to a unique filename with .tmp (.txt) extensions Windows Temporary Folder to avoid write-permission and other permissions issues
    2. Move temporary file to destination folder
    3. Rename temporary file to destination filename

    Hope it helps :-)

提交回复
热议问题