asp.net 下载 错误 CS0246: 找不到类型或命名空间名称"FileInfo1"(是否缺少 using 指令或程序集引用?)
错误CS0246:找不到类型或命名空间名称“FileInfo1”(是否缺少using指令或程序集引用?)usingSystem;usingSystem.Collectio...
错误 CS0246: 找不到类型或命名空间名称“FileInfo1”(是否缺少 using 指令或程序集引用?)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class xiazai : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath( @"\UserFile\" );//这里注意了,你得指明要下载文件的路径.
if ( System.IO.File.Exists( filePath ) )
{
FileInfo1 file = new FileInfo1( filePath );//就是这一行提示我出错的!!!!
Response.ContentEncoding = System.Text.Encoding.GetEncoding( "UTF-8" ); //解决中文乱码
Response.AddHeader( "Content-Disposition", "attachment; filename=" + Server.UrlEncode( file.Name ) ); //解决中文文件名乱码
Response.AddHeader( "Content-length", file.Length.ToString() );
Response.ContentType = "appliction/octet-stream";
Response.WriteFile( file.FullName );
Response.End();
}
}
}
本人小白 在学习asp.net 望高人指点 如何实现下载功能 展开
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class xiazai : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath( @"\UserFile\" );//这里注意了,你得指明要下载文件的路径.
if ( System.IO.File.Exists( filePath ) )
{
FileInfo1 file = new FileInfo1( filePath );//就是这一行提示我出错的!!!!
Response.ContentEncoding = System.Text.Encoding.GetEncoding( "UTF-8" ); //解决中文乱码
Response.AddHeader( "Content-Disposition", "attachment; filename=" + Server.UrlEncode( file.Name ) ); //解决中文文件名乱码
Response.AddHeader( "Content-length", file.Length.ToString() );
Response.ContentType = "appliction/octet-stream";
Response.WriteFile( file.FullName );
Response.End();
}
}
}
本人小白 在学习asp.net 望高人指点 如何实现下载功能 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询