Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 如何将文件保存在wp7';来自Web服务器的应用程序沙盒?_File_Http_Windows Phone 7_Save - Fatal编程技术网

File 如何将文件保存在wp7';来自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

在我的应用程序中,我必须通过http协议保存来自Web服务器的文本文件和二进制文件。有人能给我一些关于如何继续的提示吗?

你可以下载这些文件并将它们复制到独立的存储中

像这样的

        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);
如果(读)