posts - 157, comments - 188, trackbacks - 16, articles - 1
  博客园 :: 首页 :: 新随笔 ::  :: 订阅 订阅 :: 管理

上传和下载

Posted on 2006-06-23 15:53 过江 阅读(105) 评论(0)  编辑 收藏 所属分类: asp.net2003 C#经典方法

 

//上传:

用个FileUpload1控键

string sFileName;

sFileName 
= FileUpload1.FileName;

string sFilePath = Server.MapPath("File");

string strPath = System.IO.Path.Combine(sFilePath, FileUpload1.FileName);

FileUpload1.PostedFile.SaveAs(strPath);

//下载:

string filepath = Server.MapPath("File");

string filename = //下载文件名;

string path = filepath + filename;

Response.Clear();

Response.ContentType 
= "application/octet-stream";

Response.AddHeader(
"Content-Disposition""attachment;FileName=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));

Response.WriteFile(path);

Response.End();

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  博客园首页

  新闻频道

  社区

  小组

  博问

  网摘

  闪存

  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2006-06-23 16:06 编辑过
成果网帮您增加网站收入


相关链接: