C # Learning process-Data flow

Source: Internet
Author: User

In order to save the data in a file or get it from a file, you need to use a class in the System.IO namespace. These classes include the file class that represents one of the files on the disk, and the directory class that represents the catalog (also known as a folder in Windows).

The Directory class exposes static methods for creating, moving, and browsing directories. All methods of the directory class are static. Therefore, instead of creating an instance of this class, you can call all the methods of the class.

To implement the binary read and write of the file:

  

usingSystem;usingSystem.IO;namespaceimplementingbinaryreadwritetofile{classTester {Const intSizebuff =1024x768;  Public Static voidMain () {//Create an instance and execute itTester T =NewTester ();        T.run (); }        //Pass it a directory name to execute it        Private voidRun () {//The files that are readStream InputStream =File.openread (@"C:\test\source\test1.cs"); //the file to write toStream OutputStream =File.openwrite (@"C:\test\source\test1.bak"); //Create a cache of saved files            byte[] buffer =NewByte[sizebuff]; intBytesread; //when the Read method continuously returns bytes, they are constantly written to the output data stream             while((Bytesread =inputstream.read (buffer,0, Sizebuff)) >0) {outputstream.write (buffer,0, Bytesread);            } inputstream.close ();        Outputstream.close (); }    }

C # Learning process-Data flow

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.