How to create a file
The namespace used for file creation is System.IO which contains all the classes and functions regarding file handling such as FileStream, StreamReader etc.
FileStream is used for reading and writing operations.
StreamReader is used to read characters from a byte stream.
Source code for creating a file
Dim fs As FileStream
fs = New FileStream("newWordFile.docx", FileMode.Create, FileAccess.Write)
FileStream takes three parameters:
First is the path and name of the file being created.
Second is the file mode, there are six types of file modes:
FileMode.Append
FileMode.Create
FileMode.CreateNew
FileMode.Open
FileModeOpenAndCreate
FileMode.Truncate
Third is the FileAccess, there are three types of FileAccess:
FileAccess.Read
FileAccess.Write
FileAccess.ReadWrite
Related articles
0 comments:
Post a Comment