Jimmu John Jimmu John - 4 months ago 25
Vb.net Question

Get date creation or date modified of a file?

I want to get creation date, last modify date other details relating to files, and adding them to a datagridview. Currently I am getting the file information by using

directory.getfiles
.
Here's what i got so far:

Dim paths() As String = IO.Directory.GetFiles("mypath")

For Each sFile As String In paths
Dim fileNameOnly As String = Path.GetFileNameWithoutExtension(sFile)
gridview.Rows.Add(fileNameOnly)
Next

Answer

This is how I would grab both the created date, and the last write time.

For each sfile as datetime.tostring in paths
     Dim fileCreatedDate As DateTime = File.GetCreationTime(paths)
     Dim fileLastWrite as DateTime = File.GetLastWriteTime(path)
Next
Comments