Displaying the build date

前端 未结 25 2034
感动是毒
感动是毒 2020-11-22 11:36

I currently have an app displaying the build number in its title window. That\'s well and good except it means nothing to most of the users, who want to know if they have t

25条回答
  •  孤街浪徒
    2020-11-22 12:13

    I am just C# newbie so maybe my answer sound silly - I display the build date from the date the executable file was last written to:

    string w_file = "MyProgram.exe"; 
    string w_directory = Directory.GetCurrentDirectory();
    
    DateTime c3 =  File.GetLastWriteTime(System.IO.Path.Combine(w_directory, w_file));
    RTB_info.AppendText("Program created at: " + c3.ToString());
    

    I tried to use File.GetCreationTime method but got weird results: the date from the command was 2012-05-29, but the date from the Window Explorer showed 2012-05-23. After searching for this discrepancy I found that the file was probably created on 2012-05-23 (as shown by Windows Explorer), but copied to the current folder on 2012-05-29 (as shown by File.GetCreationTime command) - so to be on the safe side I am using File.GetLastWriteTime command.

    Zalek

提交回复
热议问题