Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to find creation date of an exe

How to find creation date of an exe

Scheduled Pinned Locked Moved Visual Basic
csharptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AR Reddy
    wrote on last edited by
    #1

    I want to find the creation date of an exe. I am using the following code. Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer Dim fHandle As Integer fHandle = CreateFile(FileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0) Using this handle, with some more code we can find the creation date. This is working fine in VB. But not working in VB.net. CreateFile is returning -1 in VB.net. Could anyone of you please tell me why it is not working in VB.net and is there any other way(methods) to find the creation date of an vb.exe file. Thanks in advance,

    AR Reddy

    T T L 3 Replies Last reply
    0
    • A AR Reddy

      I want to find the creation date of an exe. I am using the following code. Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer Dim fHandle As Integer fHandle = CreateFile(FileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0) Using this handle, with some more code we can find the creation date. This is working fine in VB. But not working in VB.net. CreateFile is returning -1 in VB.net. Could anyone of you please tell me why it is not working in VB.net and is there any other way(methods) to find the creation date of an vb.exe file. Thanks in advance,

      AR Reddy

      T Offline
      T Offline
      Tom Deketelaere
      wrote on last edited by
      #2
          Dim file As New System.IO.FileInfo("path to file")
          Dim creationdate As DateTime = file.CreationTime
      

      That should do it

      1 Reply Last reply
      0
      • A AR Reddy

        I want to find the creation date of an exe. I am using the following code. Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer Dim fHandle As Integer fHandle = CreateFile(FileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0) Using this handle, with some more code we can find the creation date. This is working fine in VB. But not working in VB.net. CreateFile is returning -1 in VB.net. Could anyone of you please tell me why it is not working in VB.net and is there any other way(methods) to find the creation date of an vb.exe file. Thanks in advance,

        AR Reddy

        T Offline
        T Offline
        Thomas Stockwell
        wrote on last edited by
        #3

        System.IO.File.GetCreation???(string filename) Look for a method similar to the above in .NET and run it on the specified file.

        Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my Blog

        1 Reply Last reply
        0
        • A AR Reddy

          I want to find the creation date of an exe. I am using the following code. Public Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer Dim fHandle As Integer fHandle = CreateFile(FileName, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0) Using this handle, with some more code we can find the creation date. This is working fine in VB. But not working in VB.net. CreateFile is returning -1 in VB.net. Could anyone of you please tell me why it is not working in VB.net and is there any other way(methods) to find the creation date of an vb.exe file. Thanks in advance,

          AR Reddy

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Dim objFileInfo As New FileInfo("D:\64.jpg") 'To get the creation, lastaccess, lastwrite time of this file Dim dtCreationDate As DateTime = objFileInfo.CreationTime Dim dtLastAccessTime As DateTime = objFileInfo.LastAccessTime Dim dtLastWriteTime As DateTime = objFileInfo.LastWriteTime Found at: http://www.devasp.net/net/articles/display/215.html[^] Or Dim fileName As String = "C:\MyPath\MyFile.txt" If File.Exists(fileName) Then Label_CreationTime.Text = File.GetCreationTime(fileName).ToString Label_LastAccess.Text = File.GetLastAccessTime(fileName).ToString Label_LastWrite.Text = File.GetLastWriteTime(fileName).ToString End If Found at: http://www.codeproject.com/KB/dotnet/FileTime.aspx[^] If you need anymore help. Let me know.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups