请问除了FTP外有没有其他办法实现超大文件下载?
最好提供参考资料。
谢谢!
12 个解决方案
#1
搜索吧
#2
http://support.microsoft.com/kb/812406/zh-cn
#3
http://support.microsoft.com/kb/888420/zh-cn
#4
没用过,帮顶
#5
采取分块下载应该可以
#6
分块下载,测试文件 3.8GB, OK
protected void Page_Load(object sender, EventArgs e)
{
string downFilePath = @"D:\openSUSE-10.2-GM-DVD-i386.iso"; // test with 3.8GB, ok // Server.MapPath("~/files/somefile.iso");
System.IO.FileInfo downFileInfo = new System.IO.FileInfo(downFilePath);
if (!downFileInfo.Exists) throw new Exception("文件不存在。");
const int CHUNK_SIZE = 10000;
byte[] buffer = new byte[CHUNK_SIZE];
Response.Clear();
using (System.IO.FileStream iStream = System.IO.File.OpenRead(downFilePath)) {
long dataLengthToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=" + Server.UrlPathEncode(downFileInfo.Name));
while (dataLengthToRead > 0 && Response.IsClientConnected) {
int lengthRead = iStream.Read(buffer, 0, CHUNK_SIZE);
Response.OutputStream.Write(buffer, 0, lengthRead);
Response.Flush();
dataLengthToRead = dataLengthToRead - lengthRead;
}
}
Response.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
string downFilePath = @"D:\openSUSE-10.2-GM-DVD-i386.iso"; // test with 3.8GB, ok // Server.MapPath("~/files/somefile.iso");
System.IO.FileInfo downFileInfo = new System.IO.FileInfo(downFilePath);
if (!downFileInfo.Exists) throw new Exception("文件不存在。");
const int CHUNK_SIZE = 10000;
byte[] buffer = new byte[CHUNK_SIZE];
Response.Clear();
using (System.IO.FileStream iStream = System.IO.File.OpenRead(downFilePath)) {
long dataLengthToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=" + Server.UrlPathEncode(downFileInfo.Name));
while (dataLengthToRead > 0 && Response.IsClientConnected) {
int lengthRead = iStream.Read(buffer, 0, CHUNK_SIZE);
Response.OutputStream.Write(buffer, 0, lengthRead);
Response.Flush();
dataLengthToRead = dataLengthToRead - lengthRead;
}
}
Response.Close();
}
#7
mark
#8
学习
#9
为什么不做FTP??
#10
up...
#11
回复人:net_lover(【孟子E章】)
http://support.microsoft.com/kb/888420/zh-cn
真是气死我了,我找到for .net 2.0的补丁,装完了用TransmitFile还是那个错误!
http://support.microsoft.com/kb/888420/zh-cn
真是气死我了,我找到for .net 2.0的补丁,装完了用TransmitFile还是那个错误!
#12
顶
#1
搜索吧
#2
http://support.microsoft.com/kb/812406/zh-cn
#3
http://support.microsoft.com/kb/888420/zh-cn
#4
没用过,帮顶
#5
采取分块下载应该可以
#6
分块下载,测试文件 3.8GB, OK
protected void Page_Load(object sender, EventArgs e)
{
string downFilePath = @"D:\openSUSE-10.2-GM-DVD-i386.iso"; // test with 3.8GB, ok // Server.MapPath("~/files/somefile.iso");
System.IO.FileInfo downFileInfo = new System.IO.FileInfo(downFilePath);
if (!downFileInfo.Exists) throw new Exception("文件不存在。");
const int CHUNK_SIZE = 10000;
byte[] buffer = new byte[CHUNK_SIZE];
Response.Clear();
using (System.IO.FileStream iStream = System.IO.File.OpenRead(downFilePath)) {
long dataLengthToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=" + Server.UrlPathEncode(downFileInfo.Name));
while (dataLengthToRead > 0 && Response.IsClientConnected) {
int lengthRead = iStream.Read(buffer, 0, CHUNK_SIZE);
Response.OutputStream.Write(buffer, 0, lengthRead);
Response.Flush();
dataLengthToRead = dataLengthToRead - lengthRead;
}
}
Response.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
string downFilePath = @"D:\openSUSE-10.2-GM-DVD-i386.iso"; // test with 3.8GB, ok // Server.MapPath("~/files/somefile.iso");
System.IO.FileInfo downFileInfo = new System.IO.FileInfo(downFilePath);
if (!downFileInfo.Exists) throw new Exception("文件不存在。");
const int CHUNK_SIZE = 10000;
byte[] buffer = new byte[CHUNK_SIZE];
Response.Clear();
using (System.IO.FileStream iStream = System.IO.File.OpenRead(downFilePath)) {
long dataLengthToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=" + Server.UrlPathEncode(downFileInfo.Name));
while (dataLengthToRead > 0 && Response.IsClientConnected) {
int lengthRead = iStream.Read(buffer, 0, CHUNK_SIZE);
Response.OutputStream.Write(buffer, 0, lengthRead);
Response.Flush();
dataLengthToRead = dataLengthToRead - lengthRead;
}
}
Response.Close();
}
#7
mark
#8
学习
#9
为什么不做FTP??
#10
up...
#11
回复人:net_lover(【孟子E章】)
http://support.microsoft.com/kb/888420/zh-cn
真是气死我了,我找到for .net 2.0的补丁,装完了用TransmitFile还是那个错误!
http://support.microsoft.com/kb/888420/zh-cn
真是气死我了,我找到for .net 2.0的补丁,装完了用TransmitFile还是那个错误!
#12
顶