1. What is a stream? : A stream is used to transmit data between a carrier and a carrier. [The carrier is the carrier of data. For example, if the data is stored on the hard disk, the hard disk is the carrier, and the U disk is the carrier, and so on]
2. How does a stream transmit data? : Transfer of one byte and one byte. To put it bluntly, it refers to the transfer of byte arrays. [Byte array is a continuous memory space]
3. The object must be converted to a byte array before being transmitted using a stream.
4. Read File essence: string ----> encoding, serialization, and conversion of strings into byte arrays ---> byte [] ---> fs [FileStream] ---> File
5. essence of writing a file: file ---> fs [FileStream] ---> byte [] ---> decoding, deserialization, and conversion of byte arrays into strings ---> string
6. When a stream writes a file [Write], a new thread is automatically called to Write the file. Therefore, the buffer zone must be cleared after the file Write operation is completed. flush (); fs is an instance of FileStream, that is, ---> clear the unmanaged memory. Because a new file will be created during file write operations, and the Windows system will call the windows code for the non-hosted memory to exist. When fs. Flush () is called, the main thread waits for the write from the thread to finish, which is equivalent to calling EndInvoke (). It automatically implements the IDisposable interface to release the unmanaged memory.
7. garbled characters may occur when reading files because ---> the encoder does not use the same character set. For example: UTF8ENCODING, gb2312, UNICODE, etc.
8. stream classification:
Byte [] ----------> file stream ---------> File
Byte [] ---------> network stream ---------> Network
Byte [] ---------> memory stream ---------> Object
Byte [] ---------> cache stream ---------> another stream