我们使用下面的行来获取文件的上次访问日期和时间.
DateTime dtLastAccesstime = File.GetLastAccessTime(sFilePath);
Run Code Online (Sandbox Code Playgroud)
但是我们面临着奇怪的问题,上面的调用本身会修改Last访问时间.因此,我们有效地将当前时间作为上次访问时间.
我们的一个WinForm在Form.Show上给出了以下异常.表单的不透明度设置为1%.我们观察到,如果我们将Opacity设置为100%,则错误消失.当机器(非应用程序)长时间运行而没有重新启动时,通常会出现错误,通常在2天后发生.
例外详情如下:
System.ComponentModel.Win32Exception: Not enough storage is available to process this command
at System.Windows.Forms.Form.UpdateLayered()
at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmCreate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
MessageNot enough storage is available to process this command
StackTrace at System.Windows.Forms.Form.UpdateLayered()
at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmCreate(Message& m) …Run Code Online (Sandbox Code Playgroud)