Asp. Summary of FileStream objects in net

Source: Internet
Author: User
The Asp.net|stream| object FileStream object provides a channel for the read and write operation of a file, while the file object provides a file handle, in which the operation of the FileStream object is relatively simple.

Creating FileStream objects

You can create a FileStream object either by using the Create method or the open method of the file object or by using the constructor of the FileStream object



Create method using the File object
Dim mikecatstream As FileStream
Mikecatstream=file.create ("C:\mikecat.txt")




Use the Open method of the File object
Dim mikecatstream As FileStream
Mikecatstream=file.open ("C:\mikecat.txt,filemode.openorcreate,fileaccess.write")



Using the constructor of the FileStream object
Dim mikecatstream As New FileStream ("C:\mikecat.txt", Filemode.open,fileaccess.write)



The main methods of FileStream objects

The 2 most important methods for FileStream objects in file read and write operations are the lock and unlock methods. Because the FileStream object provides a channel for file reading and writing, one file may have multiple file channels operating on the file, sometimes in order to avoid data write and read confusion, the need for a single channel operation, you can use the lock method to lock the file to prevent other processes to operate on the file. After the operation, you can use the Unlock method to unlock files that have already been locked and allow other processes to manipulate the files.

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.