File Information : File « File Directory « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » File Directory » FileScreenshots 
File Information
  


Imports System.IO

Imports System.Windows.Forms

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.txtDisplay = New System.Windows.Forms.TextBox
        Me.cmdCreate = New System.Windows.Forms.Button
        Me.cmdChangeDate = New System.Windows.Forms.Button
        Me.cmdGetInfo = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        Me.txtDisplay.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom_
                    Or System.Windows.Forms.AnchorStyles.Left_
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.txtDisplay.Location = New System.Drawing.Point(979)
        Me.txtDisplay.Multiline = True
        Me.txtDisplay.ReadOnly = True
        Me.txtDisplay.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtDisplay.Size = New System.Drawing.Size(280168)
        Me.txtDisplay.TabIndex = 9
        '
        Me.cmdCreate.Location = New System.Drawing.Point(939)
        Me.cmdCreate.Size = New System.Drawing.Size(8824)
        Me.cmdCreate.TabIndex = 8
        Me.cmdCreate.Text = "Create"
        '
        Me.cmdChangeDate.Location = New System.Drawing.Point(20139)
        Me.cmdChangeDate.Size = New System.Drawing.Size(8824)
        Me.cmdChangeDate.TabIndex = 7
        Me.cmdChangeDate.Text = "Change Date"
        '
        Me.cmdGetInfo.Location = New System.Drawing.Point(10539)
        Me.cmdGetInfo.Size = New System.Drawing.Size(8824)
        Me.cmdGetInfo.TabIndex = 6
        Me.cmdGetInfo.Text = "Get Info"
        '
        Me.TextBox1.Location = New System.Drawing.Point(911)
        Me.TextBox1.Size = New System.Drawing.Size(28021)
        Me.TextBox1.TabIndex = 5
        Me.TextBox1.Text = "c:\myfile.txt"
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(298259)
        Me.Controls.Add(Me.txtDisplay)
        Me.Controls.Add(Me.cmdCreate)
        Me.Controls.Add(Me.cmdChangeDate)
        Me.Controls.Add(Me.cmdGetInfo)
        Me.Controls.Add(Me.TextBox1)
        Me.Font = New System.Drawing.Font("Tahoma"8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents txtDisplay As System.Windows.Forms.TextBox
    Friend WithEvents cmdCreate As System.Windows.Forms.Button
    Friend WithEvents cmdChangeDate As System.Windows.Forms.Button
    Friend WithEvents cmdGetInfo As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

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

    End Sub

    Private Sub cmdGetInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles cmdGetInfo.Click
        Try
            Dim MyFile As New FileInfo("c:\myfile.txt")
            Out("Length in bytes: " & MyFile.Length)
            Out("Attribute list: " & MyFile.Attributes.ToString)
            Out("Stored in: " & MyFile.DirectoryName)
            Out("Created: " & MyFile.CreationTime)
        Catch err As Exception
            Out(err.Message)
        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.EventArgsHandles cmdChangeDate.Click
        Try
            Dim MyFile As New FileInfo("c:\myfile.txt")
            MyFile.LastWriteTime = DateTime.Today.Add(TimeSpan.FromDays(100))
            Out("Time updated.")
        Catch err As Exception
            Out(err.Message)
        End Try
    End Sub
End Class

   
    
  
Related examples in the same category
1.Delete *.Bak under a directoryDelete *.Bak under a directory
2.Change file attribute for *.*
3.Get Files under an Directory and print its Full Name and LengthGet Files under an Directory and print its Full Name and Length
4.Find Hidden File under a directoryFind Hidden File under a directory
5.Update file create time, last access time and last write timeUpdate file create time, last access time and last write time
6.Get Invalid File Name CharsGet Invalid File Name Chars
7.Delete a file if exist
8.Is it a File or a DirectoryIs it a File or a Directory
9.File Time: created, last modified and accessedFile Time: created, last modified and accessed
10.English File Size
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.