C#窗口编程中的文件处理 [英] File Handling in C# Window Programming
本文介绍了C#窗口编程中的文件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过Windows应用程序在C#中通过目录查找最后打开的文件名.对我来说这很紧急..
How to find the lastly open file name through a directory by windows application in C#. Its very urgent for me..
推荐答案
此代码如何:
What about this code:
var directory = new DirectoryInfo("C:\\Temp");
var myFile = (from f in directory.GetFiles()
orderby f.LastWriteTime descending
select f).First();
MessageBox.Show(myFile.Name.ToString());
由于各种原因,可能会发生打开"文件的情况,根据操作的不同,您有几种方法:说读或写.假设您要观看NTFS文件系统.
您可以查看以下内容:
-USN(写):在NTFS上的眼睛 [http://www.donationcoder.com/forum/index.php?topic=22695 [ http://support.microsoft.com/kb/310399 [ ^ ]),然后读取日志
- FileSystemWatcher [ EyeHook [ ^ ](读/写)
-当然,您可以使用 FileInfo.LastAccessTime [ ^ ](或 LastWriteTime [
As "opening" a file might occur for various reasons, you have several means depending on the operation: let''s say read or write. And let''s suppose you want to watch an NTFS file system.
You can take a look at the following:
- USN (write): Eyes on NTFS[^], http://www.donationcoder.com/forum/index.php?topic=22695[^]
- Audit trail (read/write) (http://support.microsoft.com/kb/310399[^]), and reading the logs
- FileSystemWatcher[^] (write)
- EyeHook[^] (read/write)
- and of course, you can use FileInfo.LastAccessTime[^] (or LastWriteTime[^]). LastAccessTime will only be relevant if it was it''s tracking was not deactivated!
这对您有帮助吗?
将最近使用的文件(MRU)列表添加到Windows应用程序 [
May this help you:
Add Most Recently Used Files (MRU) List to Windows Applications[^]
这篇关于C#窗口编程中的文件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文