Tuesday, 11 November 2014

Get Information About a File in Visual Basic

Get Information About a File in Visual Basic

To get information about a file:
Use the GetFileInfo method to retrieve a FileInfo object that can be examined to determine its properties. The following example retrieves a FileInfo object for the file MyLogFile.log.
  
    Dim information As System.IO.FileInfo
    information = My.Computer.FileSystem.GetFileInfo("C:\samplefile.txt")

   Examine the FileInfo object to extract the information you need. The following lines of code
   report  the file's full name, last access time, and length.

    MsgBox("The file's full name is " & information.FullName & ".")
    MsgBox("Last access time is " & information.LastAccessTime & ".")
    MsgBox("The length is " & information.Length & ".")

No comments:

Post a Comment