因为IE调用word很慢,所以客户要求这么做。虽然右击另存是可以的,但是我知道以前ASP下利用组件是可以实现点击后让用户选择是打开还是保存到本地的,ASP.Net下有没有高手做过?
顶一下也会给一分哦。能实现的解答,第一位至少50分。
8 个解决方案
#1
那就用WEB SERVICE吧。
#2
让用户下载到本地也行。
#3
linkbutton
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\a.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+fi.Name);
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\a.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+fi.Name);
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
#4
在PAGE_LOAD里写如
string fileName = Request.Params["fileName"];
if(string Name !=null)
{
string filePath = @"c:\mydoc"
FileStream MyFileStream = new FileStream(filePath +fileName,FileMode.Open);
long FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,Encoding.UTF8 ));
Response.ContentType="application/ms-word";
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
Response.Write("文件不存在!");
}
string fileName = Request.Params["fileName"];
if(string Name !=null)
{
string filePath = @"c:\mydoc"
FileStream MyFileStream = new FileStream(filePath +fileName,FileMode.Open);
long FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,Encoding.UTF8 ));
Response.ContentType="application/ms-word";
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
Response.Write("文件不存在!");
}
#5
新建一个页读取文件然后再向客户端写流就行了.
#6
如果文件名中文则
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
#7
http://blog.csdn.net/yx10/archive/2005/06/12/392892.aspx
#8
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
这个是生成在服务器的
各位都想得太复杂了,其实只要做一个_blank的href就可以了
这个是生成在服务器的
各位都想得太复杂了,其实只要做一个_blank的href就可以了
#1
那就用WEB SERVICE吧。
#2
让用户下载到本地也行。
#3
linkbutton
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\a.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+fi.Name);
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\a.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+fi.Name);
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
#4
在PAGE_LOAD里写如
string fileName = Request.Params["fileName"];
if(string Name !=null)
{
string filePath = @"c:\mydoc"
FileStream MyFileStream = new FileStream(filePath +fileName,FileMode.Open);
long FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,Encoding.UTF8 ));
Response.ContentType="application/ms-word";
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
Response.Write("文件不存在!");
}
string fileName = Request.Params["fileName"];
if(string Name !=null)
{
string filePath = @"c:\mydoc"
FileStream MyFileStream = new FileStream(filePath +fileName,FileMode.Open);
long FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,Encoding.UTF8 ));
Response.ContentType="application/ms-word";
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
Response.Write("文件不存在!");
}
#5
新建一个页读取文件然后再向客户端写流就行了.
#6
如果文件名中文则
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
#7
http://blog.csdn.net/yx10/archive/2005/06/12/392892.aspx
#8
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
这个是生成在服务器的
各位都想得太复杂了,其实只要做一个_blank的href就可以了
这个是生成在服务器的
各位都想得太复杂了,其实只要做一个_blank的href就可以了