我想将图像存储到本地文件夹中,该文件夹是从http服务器接收的。
请求(http://myServer:myPort/?imageID=5)传递一个"tif-image-file“。如果我在Internet-Explorer中输入这个请求,它就能工作!
我的c#代码:
(...)
Uri myUri = new Uri("http://myServer:myPort/?imageID=5");
StorageFile myFile = StorageFile.GetFileFromApplicationUriAsync(myUri);
(...)但是"myFile“总是空的:(
我做错什么了?
谢谢!
看不见
发布于 2012-10-30 21:17:20
好的,这是我的解决方案:
CreationCollisionOption.ReplaceExisting);
尝试{ var download =新BackgroundDownloader().CreateDownload(myUri,myFile);等待download.StartAsync();}捕获(异常E) { ... }
下一个问题是,只有当我每次将Release-Mode从"X64“更改为"AnyCPU”时才有效,反之亦然。如果我不改变发布模式,我的应用程序什么也不做。没有例外,没有程序崩溃。
这是一个bug吗?
(很抱歉我的英语不好...)
发布于 2012-10-25 17:49:02
建议使用GetFileFromApplicationUriAsync方法加载本地应用程序资源。所以它不适合你的情况。您需要使用CreateStreamedFileAsnyc方法创建新的Storage文件:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.createstreamedfileasync.aspx
编辑:在您的情况下,使用CreateStreamedFileFromUriAsync():http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.createstreamedfilefromuriasync.aspx会更容易
https://stackoverflow.com/questions/13065799
复制相似问题