472,961 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Most recent file

Lee
I have an application where I need to find the most recent file placed in a
folder. For example, my users periodically place an image file with the
format "ImageXXXX.jpg" (where XXXX is some arbitrary number) and I need to
get the latest file in the folder. Does anyone have a .NET solution to this
problem. Any help would be greatly appreciated
Thanks,
Lee

Aug 21 '06 #1
4 2092
Would you not be able to use FileSystemWatcher?

It would get hit the instant a file would be created in your folder - or
subfolder.

Miro
-New to VB.net so you may want some other opinions.

"Lee" <le**********@philips.comwrote in message
news:8C**********************************@microsof t.com...
>I have an application where I need to find the most recent file placed in a
folder. For example, my users periodically place an image file with the
format "ImageXXXX.jpg" (where XXXX is some arbitrary number) and I need to
get the latest file in the folder. Does anyone have a .NET solution to
this
problem. Any help would be greatly appreciated
Thanks,
Lee

Aug 21 '06 #2
Lee
Not really. I don't think I explained the problem very well. I have a list
of files with a *.jpg extension and I need to find the most recent file in
the list which may not be the most recent file in the folder because other
people may have put files in there without the *.jpg extension.
"Miro" wrote:
Would you not be able to use FileSystemWatcher?

It would get hit the instant a file would be created in your folder - or
subfolder.

Miro
-New to VB.net so you may want some other opinions.

"Lee" <le**********@philips.comwrote in message
news:8C**********************************@microsof t.com...
I have an application where I need to find the most recent file placed in a
folder. For example, my users periodically place an image file with the
format "ImageXXXX.jpg" (where XXXX is some arbitrary number) and I need to
get the latest file in the folder. Does anyone have a .NET solution to
this
problem. Any help would be greatly appreciated
Thanks,
Lee


Aug 21 '06 #3
You could still tie into filesystemwatcher. Just iterate the files with
that extension you seek when watcher indicates a file has changed, and look
at their properties of all files using the FileInfo class.

something like:FileInfo fFile = new FileInfo(theiteratedfilename);
DateTime fred = fFile.CreationTime.ToString()

Subtract the created date from datetime.now using timespan classes subtract
method to give you span.Seconds, and you have how long ago the file was
created.

If that figure is less than the last files figure then the current file in
the iteration is the most recent. Just repeat until all the files are
checked.

Regards

John Timney (MVP)
"Lee" <le**********@philips.comwrote in message
news:36**********************************@microsof t.com...
Not really. I don't think I explained the problem very well. I have a
list
of files with a *.jpg extension and I need to find the most recent file in
the list which may not be the most recent file in the folder because other
people may have put files in there without the *.jpg extension.
"Miro" wrote:
>Would you not be able to use FileSystemWatcher?

It would get hit the instant a file would be created in your folder - or
subfolder.

Miro
-New to VB.net so you may want some other opinions.

"Lee" <le**********@philips.comwrote in message
news:8C**********************************@microso ft.com...
>I have an application where I need to find the most recent file placed
in a
folder. For example, my users periodically place an image file with
the
format "ImageXXXX.jpg" (where XXXX is some arbitrary number) and I need
to
get the latest file in the folder. Does anyone have a .NET solution to
this
problem. Any help would be greatly appreciated
Thanks,
Lee



Aug 21 '06 #4
Lee
Thanks, John. I'll work with that.
Regards,
Lee
"John Timney (MVP)" wrote:
You could still tie into filesystemwatcher. Just iterate the files with
that extension you seek when watcher indicates a file has changed, and look
at their properties of all files using the FileInfo class.

something like:FileInfo fFile = new FileInfo(theiteratedfilename);
DateTime fred = fFile.CreationTime.ToString()

Subtract the created date from datetime.now using timespan classes subtract
method to give you span.Seconds, and you have how long ago the file was
created.

If that figure is less than the last files figure then the current file in
the iteration is the most recent. Just repeat until all the files are
checked.

Regards

John Timney (MVP)
"Lee" <le**********@philips.comwrote in message
news:36**********************************@microsof t.com...
Not really. I don't think I explained the problem very well. I have a
list
of files with a *.jpg extension and I need to find the most recent file in
the list which may not be the most recent file in the folder because other
people may have put files in there without the *.jpg extension.
"Miro" wrote:
Would you not be able to use FileSystemWatcher?

It would get hit the instant a file would be created in your folder - or
subfolder.

Miro
-New to VB.net so you may want some other opinions.

"Lee" <le**********@philips.comwrote in message
news:8C**********************************@microsof t.com...
I have an application where I need to find the most recent file placed
in a
folder. For example, my users periodically place an image file with
the
format "ImageXXXX.jpg" (where XXXX is some arbitrary number) and I need
to
get the latest file in the folder. Does anyone have a .NET solution to
this
problem. Any help would be greatly appreciated
Thanks,
Lee



Aug 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nova's Taylor | last post by:
Hi folks, I am a newbie to Python and am hoping that someone can get me started on a log parser that I am trying to write. The log is an ASCII file that contains a process identifier (PID),...
3
by: Suresh Kumaran | last post by:
How do you program in VB.NET to show the most recent used document in a dropdown menu? I am referring to something like in MS WORD or EXCEL where it shows the recent document the user was working...
1
by: Andibevan | last post by:
Hi All, I have written the following code to open the most recent file in a directory. It seems to be getting stuck on Set xlApp = Excel.Application It says the variable is undefined. ...
5
by: bill1313 | last post by:
I'm currently working on a component tracking file and we are using an hour meter query to always have up to date information. My problem is that I need the hour meter query to display the reading of...
4
by: bill1313 | last post by:
I'm currently working on a component tracking file and we are using an hour meter query to always have up to date information. My problem is that I need the hour meter query to display the reading of...
2
by: robert.waters | last post by:
I need to perform the following: - select the most recent X number of records in a table (there is a timestamp field) - select the Nth occurrence of X number of records ex: - most recent 10...
4
by: zacks | last post by:
Most applications whose purpose is to work with various types of files implement a "Most Recent Files" list, where the last, say, four files accessed by the application can quickly be re-opened by...
3
by: arnegrant | last post by:
I have the transfer text portion working fine, and I can select the most recent file in excel vba, but I can't get the most recent file portion of the code to work in access vba. It ends with...
1
by: lutz | last post by:
I fully admit, I am begging for some help. I am at the mercy of anyone's generous nature. I wish I had a template to follow for this one. I thank you in advance for anyone's advice. Maybe...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.