1 概要
FileInfo file = new FileInfo(f2);
file.Name
file.CreationTime
file.LastAccessTime
2 代码
using System;
using System.IO;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string fileName = "test.txt";
string f2 = Path.Combine(GetFolderPath(), fileName);
FileInfo file = new FileInfo(f2);
Console.WriteLine($"name{file.Name}");
Console.WriteLine($"name{file.CreationTime}");
Console.WriteLine($"name{file.LastAccessTime}");
Console.ReadKey();
}
static string GetFolderPath() {
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
}
}
}
3 运行结果