![](/img/trans.png)
[英]System.IO.FileNotFoundException: The system cannot find the file specified. in IIS 7 (web service project)
[英]System.IO.FileNotFoundException: 'The system cannot find the file specified (with SetWallpaperAsync)
我正在使用以下方法來設置我的 uwp 應用程序的背景圖像:
async Task<bool> SetWallpaperAsync(string localAppDataFileName)
{
bool success = false;
if (UserProfilePersonalizationSettings.IsSupported())
{
var uri = new Uri("ms-appx:///Local/" + localAppDataFileName);
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);
UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current;
success = await profileSettings.TrySetLockScreenImageAsync(file);
}
return success;
}
當我調用 await SetWallpaperAsync("StoreLogo.png"); 我收到錯誤“System.IO.FileNotFoundException:'系統找不到指定的文件”。 我猜問題是我將文件存儲在錯誤的位置,但我不知道該放在哪里。
當我調用 await SetWallpaperAsync("StoreLogo.png"); 我收到錯誤“System.IO.FileNotFoundException,但我不知道該放在哪里。
問題是你得到的文件路徑錯誤。 您可以使用ms-appdata:///local/
uri 方案訪問本地應用程序數據存儲中的文件。 例如:
ms-appdata:///local/myBinaryFile
您還可以使用ApplicationData.Current.LocalFolder API 獲取文件
使用ms-appx
URI 方案來引用來自應用程序 package 的文件。 您也可以使用InstalledLocation
API。
有關更多詳細信息,您可以參考URI 方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.