The file splitter is mainly used to solve the problem of carrying large files in real life. Due to storage medium capacity limitations, large files cannot be copied to the storage media at once, this can only be done by dividing the program into multiple files that can carry small files and copying these small files step by step, so as to carry large files. The merge operator can merge the split small files and restore the original files .. Many file processing class libraries provided in the. NET Framework SDK can be used to perform file operations in a simple and flexible manner. The main content of this article is to discuss a popular application of Visual C # In File programming-file splitters and splitters. The following describes the class libraries provided by the. NET Framework SDK used by Visual C # For segmentation and merging and their usage in this article.
I. Environment for program design, debugging and operation in this article:
(1). Microsoft Windows 2000 Server Edition.
(2). Visual Studio. NET 2003 enterprise build version,. NET Framework SDK version 4322.
Ii. Visual C # class libraries used for splitting and merging programs and their usage methods:
Visual C # The class libraries used for file programming are generally in. system. in the IO namespace, system. the I/O namespace provides access methods at the data stream and file layers. The access methods generally provide synchronous and asynchronous modes. In Visual C #, classes at the data stream level are mainly used to implement split and merge programs, including filestream, binaryreader, and binarywriter, these three categories generally provide synchronous and asynchronous modes to access file data streams. This article generally adopts the synchronous mode. Although the performance is poor, it is very convenient to use, it is not prone to errors.
Filestream is a very important class for implementing file programming in Visual C #. It is embodied in the reading and writing operations on files in the file system. The filestream class provides many constructors to adapt to various specific operations. This document uses the string corresponding to the file path and the file opening method to create and initialize a filestream instance. The syntax is as follows:
Public filestream ( String path, Filemode Mode ); |
The following code uses this constructor to create and initialize a filestream instance:
Filestream splitfilestream = new filestream ("C: \ Temp. Avi", filemode. Open );
Table 01 is a common attribute of the filestream class and its description: