本文介绍了从FTP'System.OutOfMemoryException'C#下载900MB文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过ftp下载900MB的文件.以下代码对于较小的文件似乎可以正常工作,但是在处理此较大的文件时出现了内存不足错误.任何帮助将不胜感激.

I am trying to download a 900MB file via ftp. The following code seems to work fine for smaller files but I am recieving an out of memory error when working with this large file. Any help would be appreciated.

WebClient request = new WebClient();
request.Credentials = new NetworkCredential("username", "password");

byte[] fileData = request.DownloadData("ftp://testftp01/downloadfile.exe");

FileStream file = File.Create(@"c:\temp\downloadfile.exe");
file.Write(fileData, 0, fileData.Length);
file.Close();




在此先感谢您的帮助.




Thanks in advance for any help.

推荐答案



这篇关于从FTP'System.OutOfMemoryException'C#下载900MB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 11:58