Most bogey you in a document management system, package file upload download and so on.
http://blog.csdn.net/pmy_c_l/article/details/73743843
Official Link: https://msdn.microsoft.com/zh-cn/library/system.io.filestream.read.aspx
/// <summary> ///read local file upload to server/// </summary> /// <param name= "Localfilepath" >Local file path</param> /// <param name= "Serverpath" >Server storage Path</param> Public voidReadFile (stringLocalfilepath,stringServerpath) { //string filepath = "C:\xxx";//file upload local address; //string serverpath = HttpContext.Current.Server.MapPath (".. /file/"+ fileName); //the path saved on the server Try{FileInfo fs=NewFileInfo (Localfilepath); stringFileName = fs. Name;//Get file name using(FileStream fsread =NewFileStream (Localfilepath, FileMode.Open)) { using(FileStream fswrite =NewFileStream (Serverpath, FileMode.OpenOrCreate)) {//the length of the custom array byte[] bytes =New byte[Fsread.length]; //A loop is required when the end of the file is not read while(Fsread.position <fsread.length) {//when read, the Position property automatically changes, remembering where it is currently read, in bytes//count can get the number of bytes currently read to intCount = Fsread.read (Bytes,0, Bytes. Length); if(Count = =0) { Break; } } //WriteFswrite.write (Bytes,0, fsread.length);//just write the number of bytes read to it. } } } Catch(Exception e) {Throwe; } }
. net files are uploaded to the server "Go"