就是点击图标或文字,就会出现文件另存为的窗口,什么样的代码可以实现???急求,谢谢——文件是从数据库中读出来的,点击下载的时候就会保存相应的文件,要怎么写代码?
解决方案 »
- sos:类型“System.Data.Linq.DataContext”在未被引用的程序集中定义。
- 各位Winform高手,过来帮个忙吧
- 哪个数据库建模工具可以将TABLE对象生成XML描述?PowerDesigner?
- 关于C++的结构体和C#的结构体
- 易语言做的外壳不能连接网关...在线等
- 在没有.netframework的机器上运行c#开发的程序,应该在目标机器上安装一个什么东东?在线等
- 请介绍一下分布式程序中静态变量的作用
- 调试时出现以下问题,请解答!!
- 关于asp.net
- Winform在线程中怎么让MessageBox显示置顶
- gridview 右键出菜单 不知有没有更好的方法
- COM+提交数据时都报了这么个错误“[COMException (0x8004d00e): 此事务已明地或暗地被确认或终止]”。
{
try {
FileStream myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader br = new BinaryReader(myFile);
try {
_Response.AddHeader("Accept-Ranges", "bytes");
_Response.Buffer = false;
long fileLength = myFile.Length;
long startBytes = 0;
Int16 pack = 10240;
Int16 sleep = Convert.ToInt16(Math.Floor(1000 * pack / _speed) + 1);
if (!(_Request.Headers("Range") == null)) {
_Response.StatusCode = 206;
char[] splitChar = new char[1];
splitChar(0) = "=";
splitChar(1) = "-";
string[][0] range = _Request.Headers("Range").Split("a");
startBytes = Convert.ToInt64(range(1));
}
_Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());
if ((startBytes != 0)) {
_Response.AddHeader("Content-Range", string.Format(" bytes {0}-{1}/{2}", startBytes, fileLength - 1, fileLength));
}
_Response.AddHeader("Connection", "Keep-Alive");
_Response.ContentType = "application/octet-stream";
_Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(_fileName, System.Text.Encoding.UTF8));
br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
long maxCount = Convert.ToInt64(Math.Floor((fileLength - startBytes) / pack) + 1);
long i;
for (int i = 0; i <= maxCount; i++) {
if ((_Response.IsClientConnected)) {
_Response.BinaryWrite(br.ReadBytes(pack));
Thread.Sleep(sleep);
} else {
i = maxCount;
}
}
} catch (Exception e) {
return false;
} finally {
br.Close();
myFile.Close();
}
} catch {
return false;
}
}
这一句会报错 []是无效的表达式项 range 应输入;