C# 复制文件后未更新修改日期
我正在将文件夹及其所有内容(包括子目录和文件)导入我的应用程序数据目录,以供我的应用程序使用 我尝试过很多解决方案,但最有效的是这个C# 复制文件后未更新修改日期,c#,C#,我正在将文件夹及其所有内容(包括子目录和文件)导入我的应用程序数据目录,以供我的应用程序使用 我尝试过很多解决方案,但最有效的是这个 //Create all of the directories foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories)) Directory.CreateDirectory(dirPath.Replace(SourcePat
//Create all of the directories
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
//Copy all the files & Replaces any files with the same name
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
这非常有效,但如果文件已存在于目标目录中,则会更新其数据,但其修改日期根本不会更新。复制文件时,修改日期永远不会更新,文件没有更改,只是位置而已。您如何检查修改日期?这没有意义,我能看一张截图吗?当然,您可以先执行删除操作,但存在一个问题,即Windows文件系统不反映审核更改。我还需要查看文件/文件夹权限以及运行此代码的用户。这听起来不对。我发现很难相信文件的内容会在没有设置时间戳的情况下得到更新。explorer是否正在缓存它?复制文件时,修改的日期永远不会更新,文件没有更改,只是更改了位置。