简体   繁体   English

C# 返回文件路径的最后写入日期

[英]C# To return File Path's Last Written Date

I have an action in Blueprism that will bring back all files from a base directory (including sub folders).我在 Blueprism 中有一个动作,它将带回基本目录(包括子文件夹)中的所有文件。 I also need to return the last written date.我还需要返回最后的书面日期。 Is this possible?这可能吗?

public DataTable Get_Files_ALL(string Path, string Pattern, bool Recursive)
{
DataTable Paths = new DataTable("Paths");
DataColumn PathId = new DataColumn("Path", typeof(String));
Paths.Columns.Add(PathId);

var String_Array = new string[] {};

if (Recursive)
    String_Array = Directory.GetFiles(Path, Pattern, System.IO.SearchOption.AllDirectories);
else
    String_Array = Directory.GetFiles(Path, Pattern, System.IO.SearchOption.TopDirectoryOnly);

int count = String_Array.Length;

foreach (string Path_Array in String_Array)
{
    DataRow row1 = Paths.NewRow();
    row1["Path"] = Path_Array;
    Paths.Rows.Add(row1);
};

return Paths;

} }

您可以使用以下内容获取特定文件的最后修改数据:

System.IO.File.GetLastWriteTime(path)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM