GetLastWriteTime returning 12/31/1600 7:00:00 PM

前端 未结 6 1718
栀梦
栀梦 2020-12-02 01:50

I am using the following code to write the Date Modified time of a Directory to a label

string selectedPath = comboBox1.SelectedItem.ToString();
DateTime las         


        
6条回答
  •  失恋的感觉
    2020-12-02 02:07

    In .NET CORE You will need to get the absolute path of the file. Add reference to Microsoft.Extensions.Hosting Inject that into your constructor The ContentRootPath property will be your web root.

    Grab your server path

    var Files = FIO.Directory.GetFiles("Unzipped");
    

    This will be your actual path

    var Path = string.Format(@"{0}\{1}",WebRootPath, Files[0]);
    
    var CreationDate = File.GetLastWriteTime(Path);
    

提交回复
热议问题