File 如何将文件保存在wp7';来自Web服务器的应用程序沙盒?
在我的应用程序中,我必须通过http协议保存来自Web服务器的文本文件和二进制文件。有人能给我一些关于如何继续的提示吗?你可以下载这些文件并将它们复制到独立的存储中 像这样的File 如何将文件保存在wp7';来自Web服务器的应用程序沙盒?,file,http,windows-phone-7,save,File,Http,Windows Phone 7,Save,在我的应用程序中,我必须通过http协议保存来自Web服务器的文本文件和二进制文件。有人能给我一些关于如何继续的提示吗?你可以下载这些文件并将它们复制到独立的存储中 像这样的 private void DownloadFiles() { var wc = new WebClient(); wc.OpenReadCompleted += WcOpenReadCompleted; wc.OpenReadAsync(new Uri
private void DownloadFiles()
{
var wc = new WebClient();
wc.OpenReadCompleted += WcOpenReadCompleted;
wc.OpenReadAsync(new Uri("http://myserver/myfile.file", UriKind.Absolute));
}
public static void CopyStream(Stream input, Stream output)
{
var buffer = new byte[32768];
while (true)
{
int read = input.Read(buffer, 0, buffer.Length);
if (read <= 0)
return;
output.Write(buffer, 0, read);
}
}
private static void WcOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
{
var isolatedStorageFileStream = userStoreForApplication.CreateFile("mylocalfilename");
using (isolatedStorageFileStream)
{
CopyStream(e.Result, isolatedStorageFileStream);
}
}
}
private void DownloadFiles()
{
var wc=新的WebClient();
wc.OpenReadCompleted+=WcOpenReadCompleted;
OpenReadAsync(新Uri(“http://myserver/myfile.file“,UriKind.Absolute”);
}
公共静态void CopyStream(流输入、流输出)
{
var buffer=新字节[32768];
while(true)
{
int read=input.read(buffer,0,buffer.Length);
如果(读取),您可以下载文件并将其复制到独立存储
像这样的
private void DownloadFiles()
{
var wc = new WebClient();
wc.OpenReadCompleted += WcOpenReadCompleted;
wc.OpenReadAsync(new Uri("http://myserver/myfile.file", UriKind.Absolute));
}
public static void CopyStream(Stream input, Stream output)
{
var buffer = new byte[32768];
while (true)
{
int read = input.Read(buffer, 0, buffer.Length);
if (read <= 0)
return;
output.Write(buffer, 0, read);
}
}
private static void WcOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication())
{
var isolatedStorageFileStream = userStoreForApplication.CreateFile("mylocalfilename");
using (isolatedStorageFileStream)
{
CopyStream(e.Result, isolatedStorageFileStream);
}
}
}
private void DownloadFiles()
{
var wc=新的WebClient();
wc.OpenReadCompleted+=WcOpenReadCompleted;
OpenReadAsync(新Uri(“http://myserver/myfile.file“,UriKind.Absolute”);
}
公共静态void CopyStream(流输入、流输出)
{
var buffer=新字节[32768];
while(true)
{
int read=input.read(buffer,0,buffer.Length);
如果(读)