Changes

Working with Files in Visual Basic

516 bytes added, 15:54, 10 August 2007
Writing to a File
Note that the above code example assumes that the 'C:\Temp' directory already exists. If it does not the code will fail. Working with Directories is covered in [[Working with Directories in Visual Basic]]
== Writing to a File with Visual Basic == Once a file has been opened with the appropriate options, it can be written to using the Visual Basic ''StreamWriter'' class. The ''StreamWriter'' constructor takes a ''FileStream'' as the sole parameter. The ''Write()'' and ''WriteLine()'' methods of the ''StreamWriter'' class are then used to write to the file. ''Write()'' writes the text with no new line appended to the end of each line. ''WriteLine()'' on the other hand, appends a new line to end of each line written to the file: <pre>