Imports System.IO

Public Class Form1

    Private Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click
        Try
            Dim MyFile As New FileInfo("c:\myfile.txt")
            MyFile.Create().Close()
            Out("File created.")
            Out("")
        Catch err As Exception
            Out(err.Message)
            Out("")
        End Try

    End Sub

    Private Sub cmdGetInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetInfo.Click
        Try
            Dim MyFile As New FileInfo("c:\myfile.txt")

            ' We can now access some of the following properties.
            Out("Length in bytes: " & MyFile.Length)
            Out("Attribute list: " & MyFile.Attributes.ToString)
            Out("Stored in: " & MyFile.DirectoryName)
            Out("Created: " & MyFile.CreationTime)
            Out("")

        Catch err As Exception
            Out(err.Message)
            Out("")
        End Try
    End Sub

    Public Sub Out(ByVal NewText As String) ' Utility for displaying information.
        txtDisplay.Text &= vbNewLine & NewText
        txtDisplay.SelectionStart = txtDisplay.Text.Length - 1
        txtDisplay.ScrollToCaret()
    End Sub

    Private Sub cmdChangeDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdChangeDate.Click
        Try
            Dim MyFile As New FileInfo("c:\myfile.txt")

            ' Any property we can get, we can also change.
            MyFile.LastWriteTime = DateTime.Today.Add(TimeSpan.FromDays(100))
            Out("Time updated.")
            Out("")
        Catch err As Exception
            Out(err.Message)
            Out("")
        End Try
    End Sub
End Class