【发布时间】:2024-05-01 16:50:02
【问题描述】:
我正在编写一个 wp8 应用程序。我有一个问题困扰了我几天。 我想将照片上传到服务器。我从相册中选择了一张照片,我使用 FileStream 上传它,但我无法打开它。它说访问路径被拒绝。
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
// show the img
BitmapImage bmp = new BitmapImage();
bmp.SetSource(e.ChosenPhoto);
ShowPhoto.Source = bmp;
// get path of img
string imagePath = e.OriginalFileName;
}
}
上传
if (imagePath != null)
{
FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
StreamContent imageContent = new StreamContent(fs);
}
一行:FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read); 我遇到了错误。
System.UnauthorizedAccessException:对路径“C:\Data\Users\Public\Pictures\Camera Roll\WP_20140331_001.jpg”的访问被拒绝。
我在 WMAppMainfest.xml 中选择了函数 `D_CAP_MEDIALIB_PHOTO
【问题讨论】:
标签: c# windows-phone-8