求助fileStream方法readbyte

fdjkalfjklajdf fdjkalfjklajdf 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

protected void Button1_Click(object sender, EventArgs e)
{
FileInfo fi = new FileInfo(TextBox1.Text);
byte[] buffer=new byte[fi.Length];
int UploadContentLength=0;
using(FileStream fs=new FileStream(TextBox1.Text,FileMode.Open,FileAccess.Read))
{
while (UploadContentLength < fi.Length)
{
int bytes = 0;
//fs.Read(buffer, 0, 1);
bytes = fs.ReadByte();
UploadContentLength += bytes;
}
fs.Read(buffer, 0, buffer.Length);
}
string path = Server.MapPath(@"file");
FileStream fs2 = new FileStream(Path.Combine(path,fi.Name), FileMode.Create);
fs2.Write(buffer, 0, buffer.Length);
fs2.Close();
}

起着textBox1.Text为路径,我最终生成在服务器的txt文件中第一位内容没了
...全文
评论 3
收藏 已收藏
分享
返回顶部
fdjkalfjklajdf
.NET社区 62,272 成员 668,968 内容