OperationCompositionComponent class
File methods are static and suitable for performing only one operation. All methods are performing a security check.
The fileinfo class is suitable for providing an object for a file that performs multiple operations, but only performs one security check.
Operation Directory class
Directory
Directoryinfo
Same as file class
Path class
Stream is the abstract base class of all streams. Its sub-classes include stream in memory of memorystream, stream of filestream files, stream of networkstream network devices, and other stream of bufferedstream.
Main Methods
Read (), read the stream into the byte array
Write (), write the byte array into the stream
Flush () to write the buffered stream into the target
Close (), close the stream to release resources
Binary files
Type of the data to be obtained
Text Files
Streamreader and streamwriter operate the stream as characters
Upload files
Request. Files [0]. inputstream
After obtaining the uploaded byte stream, if the byte stream is closed, it cannot be used directly later. This is because the resource has been released.
// Stream, byte array and String Conversion stream-byte array-string
Stream stream = new filestream (@ "1.html", filemode. Open, fileaccess. Read, fileshare. Read );
Byte [] bytes = new byte [stream. Length];
Stream. Read (bytes, 0, bytes. Length-1 );
String STR = encoding. utf8.getstring (bytes );
Byte [] bytes2 = encoding. utf8.getbytes (STR );
Stream streamm = new memorystream (bytes2 );