[英]File Access Denied Exeption
我写了一个简单的c#代码来发布HttpMultipartForm
格式的音频文件,当我尝试访问我的硬盘中的文件时,它会抛出一个异常,即拒绝访问路径。
using(var httpClient = new HttpClient())
{
using(var request = new HttpRequestMessage(new HttpMethod("POST"),"https://www.iotype.com/api/recognize/file"))
{
multipartContent.Add(new StringContent("MyToken"), "token");
multipartContent.Add(new ByteArrayContent(File.ReadAllBytes("C:\\audio.mp3")), "audio", Path.GetFileName("AUDIO_FILE.mp3"));
request.Content = multipartContent;
var response = await httpClient.SendAsync(request);
txtStatus.Text = response.Content.ToString();
}
}
UWP应用程序在它们可以访问的目录和文件方面受到限制。 导航限制的最简单方法是使用Windows.Storage命名空间中的WinRT类型,两个主要类是StorageFolder和StorageFile,在Windows 8和8.1的Windows运行时中,您无法使用FileStream或Directory / File类一点都不 这使得编写可移植类库变得更加困难,因此在UWP for Windows 10中放宽了这一限制,尽管您可以访问的目录和文件的限制仍然适用。 所以它不可能在UWP应用程序中使用File Class。
在UWP应用程序中存在很多限制,因为它的应用程序嵌入到窗口中,出于架构的原因而强加于安全性(应用程序域的隔离) ,它并不妨碍它存在多种管理信息的方式(读取,写入)在专用应用程序位置使用Windows API 。
本地存储:
It's a default file system for application and it's identified by LocalFolder Class .
漫游存储:
Has the same fearture than The Local Storage adding to that synchronization Data with windows Devices , identified by RoamingSettings Class.
临时存储:
As his name indicates It's used mainly for caching scenarios .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.