compact-framework2.0

Change file LastWriteDate in Compact Framework

梦想的初衷 提交于 2019-11-28 10:13:55
问题 FileSystemInfo.LastWriteTime property is readonly in CF. Is there an alternative way to change that date? 回答1: P/Invoke SetFileTime. EDIT Something along these lines (warning: untested) [DllImport("coredll.dll")] private static extern bool SetFileTime(string path, ref long creationTime, ref long lastAccessTime, ref long lastWriteTime); public void SetFileTimes(string path, DateTime time) { var ft = time.ToFileTime(); SetFileTime(path, ref ft, ref ft, ref ft); } 回答2: Here is a fuller