. net files are uploaded to the server "Go"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.