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("Pliku utworzony.")
            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("Długość w bajtach: " & MyFile.Length)
            Out("Lista atrybutów pliku: " & MyFile.Attributes.ToString)
            Out("Plik znajduje się w folderze: " & MyFile.DirectoryName)
            Out("Data utworzenia: " & 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("Czas zmodyfikowany.")
            Out("")
        Catch err As Exception
            Out(err.Message)
            Out("")
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class