我一直在使用hp的名为openview的软件程序,该程序在我们所有的计算机上提供并安装软件.每次运行软件连接时,它都会创建这些日志,我必须打开并浏览,并且厌倦了必须先搜索然后再打开的情况. 现在我已经使用下面的代码来获取所有具有* _mach.log的文件.我需要从该列表中获取帮助,并打开前面具有最高编号的列表.因此,正常的日志文件看起来像是20120516_mach.log,并且您看到的数字是该文件的创建日期,这也使我们知道上一次软件连接的运行时间. 我一直在使用下面的代码来获取文件名,而我真正想要做的是一旦它拥有最新的日志,便可以使用记事本打开它.现在下面的代码我现在要进入列表视图,并且我不想在最终结果中使用它.我想要的是当您单击按钮以打开日志时,它将在记事本中打开最新文件. 搜索文件夹的代码:
I have been working with a software program from hp called openview and it delivers and installs software on all our computers. It creates these logs each time it runs a software connect and I have to open and look through and im tired of having to search for it and then open it. now i have deen using the below code to get all the files that have *_mach.log. I need help going from that list and open the one that has the highest number in front of it. so a normal log file looks like this 20120516_mach.log, and the numbers you see are the date it was created which also lets us know when a software connect last ran. i have been using the below code to just get the file names and what i really want to do is once it has the most current log is to open it with notepad. now the below code i have going to a list view for right now and i don''t want to use it in the end result. What i want is when you click the button to open the log it opens the most current file in notepad. code for searching the folder:
Dim di As New IO.DirectoryInfo("C:\Users\Zachary\Desktop\Log") Dim diar1 As IO.FileInfo() = di.GetFiles("*_mach.log") Dim dra As IO.FileInfo 'list the names of all files in the specified directory For Each dra In diar1 ListBox1.Items.Add(dra) Next我用于使用记事本打开文件的代码:(示例)
the code i m using to open files with notepad:(example)
Process.Start("notepad.exe", "\\" & strcomputer & "\C$\Windows\System32\drivers\etc\HOSTS")帮助会很棒...
help would be great...
推荐答案\ Windows \ System32 \ drivers \ etc \ HOSTS) \Windows\System32\drivers\etc\HOSTS")
帮助会非常有用...
help would be great...
可能您的意思是最新文件".最近创建或最近写的? 以System.IO.FileInfo实例的形式获取所有有问题的文件后,可以使用System.IO.CreationTime或System.IO.LastWriteTime(取决于所需的时间)并比较时间.请参阅: msdn.microsoft/en-us/library/system.io. fileinfo.aspx [^ ]. 请记住,时间分辨率不高,是毫秒.请参阅: social.msdn.microsoft/Forums/eu/csharpgeneral/thread/bed97747-923d-4078-9ae3-04e0b0192342 [ ^ ]. 顺便说一句,许多人对如何比较System.DateTime的实例感到困惑.答案很简单:使用运算符<"或>".请参阅: msdn.microsoft/en-us/library/system.datetime.aspx [ ^ ].
更多推荐
帮助打开文件夹中的最新文件
发布评论