问题描述
我有c#应用程序.此写日志文件夹.
I have c# application. This write log in folder.
下面的代码.
if (File.Exists(@"C:\EXT_LOG\LOG.txt"))
{
File.Delete(@"C:\EXT_LOG\LOG.txt");
}
string Data = "xxxxx";
System.IO.StreamWriter file = new StreamWriter(@"C:\EXT_LOG\LOG.txt");
file.WriteLine(Data);
file.Dispose();
file.Close();
我删除文件(如果存在),并创建具有相同名称的文件.当我运行程序时,文件的创建日期不变.
I delete file, if it exist, and I create file with same name.when I run program, the creation date of file is not change.
我想Windows的任何管理器或任何文件表仍包含该文件.
I guess windows any manager or any file table still contain that file.
因此,当我删除文件时,可以删除管理器或文件表内容吗?
So, when I delete file, can I delete manager or file table content??
推荐答案
这就是Windows中的工作方式.我没有在Google中搜索为什么.但是,您似乎可以使用 System.IO.File.SetCreationTime 方法通过C#设置文件的创建日期.
That's how it works in windows. I have not searched Google for WHY. However it seems you can set the creation date of the file through C# using System.IO.File.SetCreationTime method.
public static void SetCreationTime(
string path,
DateTime creationTime
)
来源: https ://msdn.microsoft.com/zh-CN/library/system.io.file.setcreationtime(v = vs.100).aspx
这篇关于删除文件并重新创建文件后,请勿在Windows中更改创建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!