using System.IO;
FileInfo fileinfo = new FileInfo(@"文件全路径,可以从文本框或者openfiledialog里面得到。");
byte[] sr=new byte[fileinfo.Length];
FileStream fs = new FileStream(@"文件全路径",FileMode.Open);
fs.Read(sr, 0, Convert.ToInt32(sr.Length));
fs.Dispose();
fs.Close();
string filename = Server.MapPath("~/upload")+"//"+fileinfo.Name;
//在网站目录下,建立个文件夹,我这里叫upload
FileStream fsu = new FileStream(filename, FileMode.Create);
fsu.Write(sr, 0, sr.Length);
fsu.Dispose();
fsu.Close();
此方法,上传400MB的电影。
byte[] sr=new byte[fileinfo.Length];
FileStream fs = new FileStream(@"文件全路径",FileMode.Open);
fs.Read(sr, 0, Convert.ToInt32(sr.Length));
fs.Dispose();
fs.Close();
string filename = Server.MapPath("~/upload")+"//"+fileinfo.Name;
//在网站目录下,建立个文件夹,我这里叫upload
FileStream fsu = new FileStream(filename, FileMode.Create);
fsu.Write(sr, 0, sr.Length);
fsu.Dispose();
fsu.Close();
此方法,上传400MB的电影。