Utilize the Full Functionality of the Whidbey File Management - Mode, Share and Access of Files
(Page 8 of 8 )
FileMode
FileMode parameter control has the following members:
- Append – Append to an existing file or create a new file if the file not exists
- Create - Create a new file
- Open – Open the file
- OpenCreate - Open a file if exists or it will create a file
- Truncate – Remove all the contents so that its size is zero bytes
Example:
Dim objStreamReader As New
StreamReader(“C:\benoy\Mytext.txt”)
MessageBox.Show(objStreamReader.ReadToEnd()
objStreamReader.Close()
FileShare
FileShare enumeration allows you to control the share permission to access the FileStreams.
Some of the members included in the FileShare enumerations are Read, ReadWrite, Write, None, Inheritable etc.
Read command allows you to opening the file for reading.
ReadWrite command allows you to opening the file for reading and writing.
Write command allows you to opening the file for writing.
Dim objFileStream As New
FileStream(“C:\benoy\Mytext.txt”, _
FileMode. OpenOrCreateOpen,
FileAccess.ReadWrite,
FileShare.ReadWrite)
FileAccess
FileAccess enumeration allows you to control the permission to access the FileStreams.
Some of the members included in the FileAccess enumerations are Read, ReadWrite, Write etc.
Conclusion
In this article we found out how to manage windows file operations using different file level operation commands. It allows you to set file permissions, modes, access and sharing of files using VB.NET environment.
• File System Management and its uses
• File Permissions
• File modes, File Access, File Shares
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |