gpt4 book ai didi

c# - 文件名、目录名或卷标语法不正确。 (来自 HRESULT : 0x8007007B) 的异常

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:46 35 4
gpt4 key购买 nike

我在代码查找路径时收到此错误,我不明白这是什么时候发生的,我认为我做对了。

代码:

 string newUri = ImageGalleryUri.Replace("ms-appdatalocal/", "");  //Replace this part of the string with a nonspace character.
newUri = newUri.Replace("/", "\\");
newUri = newUri.Replace("%20", " "); //Replace the ASCII code for space for an actual space. For some reason I'm getting invalid character error with %20.
StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile storageFile = await folder.GetFileAsync(newUri);
DataPackage dp = new DataPackage(); //Create the DataPackage containing the clipboard content.
dp.SetBitmap(RandomAccessStreamReference.CreateFromFile(storageFile));
Clipboard.SetContent(dp);
await successDialog.ShowAsync();

错误在这一行:newUri = ms-appdata:\local\Books\Assets\Recursos para el docente\Matematicas\9\Esp\1\0\Geometria_Page_04.png

StorageFile storageFile = await folder.GetFileAsync(newUri);

最佳答案

也许试试这个:

newUri = Uri.EscapeDataString(newUri);

代替:

newUri = newUri.Replace("%20", " ");

关于c# - 文件名、目录名或卷标语法不正确。 (来自 HRESULT : 0x8007007B) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24313962/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com