我想為 Fortnite 下載一個 .ini 檔案并將其從下載移動到 LocalAppData 但是我單擊按鈕并且我的程式關閉并出現錯誤 'An exception occurred during a WebClient request.'
我留下了我的代碼影像,任何人都可以幫助我嗎?我需要下載到FortniteGame\Saved\Config\WindowsClient或者我希望能夠將檔案移動到那里。感謝任何可以提供幫助的人。
uj5u.com熱心網友回復:
你的問題有幾個問題
- 您已粘貼圖片,切勿發布代碼圖片
- 您應該始終在提出問題時粘貼內部例外
Inner Exception -> DirectoryNotFoundException: 找不到路徑“C:\Downloads\GameUserSettings.ini”的一部分。 - DownloadFile 方法采用檔案名,但您正在傳遞路徑
Reference -> https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient.downloadfile?view=net-5.0
我已經更新了代碼,它對我有用。
using (WebClient webclient = new WebClient())
webclient.DownloadFile("https://cdn.discordapp.com/attachments/897280259219656744/897643067551645757/GameUserSettings.ini", "GameUserSettings.ini");
string folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string specificFolder = Path.Combine(folder, "FortniteGame\\Saved\\Config\\WindowsClient");
string file = @"GameUserSettings.ini";
if (!Directory.Exists(specificFolder))
Directory.CreateDirectory(specificFolder);
File.Copy(file, Path.Combine(specificFolder, Path.GetFileName(file)));
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/337055.html
上一篇:更新驗證錯誤時如何使用react-hook-form手動重新渲染組件
下一篇:php無法保存圖片
