Creating a Text File
Posted by admin - Mar 31, 2008 Articles, Dani Vainstein, QTips, Text Files 0 0 Views : 241 Receive Updates For This Category
Article Tools
- Print this page
- Add Comment
- Send to Friend
- Last Updated on :
Jul 16, 2011
System.IO.File class provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The CreateText method creates or opens a file for writing UTF-8 encoded text.
The following example demonstrates some of the main members of the File class.
Dim pathStr
Dim sysIoFile, sw
pathStr = "c:\MyTest.txt"
Set sysIoFile = DotNetFactory.CreateInstance( "System.IO.File" )
If CBool( sysIoFile.Exists( pathStr ) ) = False Then
' ** Create a file to write to.
Set sw = sysIoFile.CreateText( pathStr )
sw.WriteLine("Hello")
sw.WriteLine("And")
sw.WriteLine("Welcome")
sw.Flush()
sw.Close()
End If
Set sw = Nothing : Set sysIoFile = Nothing


