473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 2117
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.