您的位置:首页 > 其它

上传控件(input type="file")的用法

2012-04-12 15:27 267 查看
//判断上传的文件是否为空
HttpPostedFile postFile = Request.Files["upfile"];
if (postFile == null || postFile.ContentLength < 0)
{ //提示为空或者其他操作

}

//如果是文本文件,读取其内容
Stream s = StreamCopyTo(postFile.InputStream);
StreamReader sr = new StreamReader(s, System.Text.Encoding.Default);
strCode = sr.ReadToEnd(); //strCode就是文本文件中的内容
s.Close();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: