Mega Code Archive

 
Categories / VB.Net / File Directory
 

File Class provides static methods for the creation, copying, deletion, moving, and opening of files

Imports System Imports System.IO Public Class Test     Public Shared Sub Main()         Dim fileLoc As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyDoc.txt")         If Not File.Exists(fileLoc) Then             Using swNew As New StreamWriter(fileLoc)                 swNew.WriteLine("Sample text")             End Using         End If         Using sr As New StreamReader(fileLoc)             Console.WriteLine(sr.ReadToEnd())         End Using     End Sub End Class