帮助打开文件夹中的最新文件

编程入门 行业动态 更新时间:2024-10-23 18:30:05
本文介绍了帮助打开文件夹中的最新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在使用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 [ ^ ].
—SA
Probably you mean "most recent file". Most recently created or most recently written? After you get all files in question in the form of the instance of System.IO.FileInfo, you can use System.IO.CreationTime or System.IO.LastWriteTime (depending on what time do you need) and compare time. Please see: msdn.microsoft/en-us/library/system.io.fileinfo.aspx[^]. Remember that the time resolution is not high, it''s a millisecond. Please see: social.msdn.microsoft/Forums/eu/csharpgeneral/thread/bed97747-923d-4078-9ae3-04e0b0192342[^]. By the way, many are confused about how to compare the instances of System.DateTime. The answer is simple: use the operator "<" or ">". Please see: msdn.microsoft/en-us/library/system.datetime.aspx[^].
—SA

更多推荐

帮助打开文件夹中的最新文件

本文发布于:2023-10-30 19:29:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543783.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   夹中   最新

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!