473,473 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Directory check for new files

I'm trying to come up with some code that will continually scan a
directory for new files and read the name of the most recent file. Does
anyone have some suggestions on how this could be accomplished? Any
help would be greatly appreciated.

Best regards,
Lorn Davies

Jul 23 '05 #1
5 2633
Lorn wrote:
I'm trying to come up with some code that will continually scan a
directory for new files and read the name of the most recent file. Does
anyone have some suggestions on how this could be accomplished? Any
help would be greatly appreciated.


That is platform-specific, so other newsgroups are better qualified to
answer it.

You probably want the Win32 function FindFirstChangeNotification(). Google
for that, to learn what forums know more about it than ours.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #2
Lorn wrote:
I'm trying to come up with some code that will continually scan a
directory for new files and read the name of the most recent file. Does
anyone have some suggestions on how this could be accomplished? Any
help would be greatly appreciated.


Standard C++ does not even known that some operating systems actually
know about directories. Thus, what you want is platform specific. That
said, you might want to look into the Boost Filesystem Library. It has
a directory_iterator that allows you to traverse a directory.
Best

Kai-Uwe Bux
Jul 23 '05 #3
Kai-Uwe Bux wrote:
Lorn wrote:
I'm trying to come up with some code that will continually scan a
directory for new files and read the name of the most recent file. Does
anyone have some suggestions on how this could be accomplished? Any
help would be greatly appreciated.


Standard C++ does not even known that some operating systems actually
know about directories. Thus, what you want is platform specific. That
said, you might want to look into the Boost Filesystem Library. It has
a directory_iterator that allows you to traverse a directory.


Agreed this is off-topic, but the OP is asking for an asynchronous trigger
when a folder changes.

A windows Explorer does this. When another process creates or deletes a
file, the folder view updates in realtime.

I'm not sure, but I suspect the Boost Filesystem Library won't do that if it
limits the library's portability.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #4
Phlip wrote:
Kai-Uwe Bux wrote:
Lorn wrote:
> I'm trying to come up with some code that will continually scan a
> directory for new files and read the name of the most recent file. Does
> anyone have some suggestions on how this could be accomplished? Any
> help would be greatly appreciated.


Standard C++ does not even known that some operating systems actually
know about directories. Thus, what you want is platform specific. That
said, you might want to look into the Boost Filesystem Library. It has
a directory_iterator that allows you to traverse a directory.


Agreed this is off-topic, but the OP is asking for an asynchronous trigger
when a folder changes.

A windows Explorer does this. When another process creates or deletes a
file, the folder view updates in realtime.

I'm not sure, but I suspect the Boost Filesystem Library won't do that if
it limits the library's portability.


True. I was thinking of a somewhat simpler solution: just maintain a
sorted list of file-names from your last scan of the directory, regularly
rescan and find the new files. Then update your list. More nifty solutions,
of course, like having the OS notify you when the directory changes, are
highly non-portable, and I agree that Boost would probably not go there.
Best

Kai-Uwe Bux
Jul 23 '05 #5
Just wanted to thank everybody for their input and suggestions. I'll
try and find another newsgroup where it's more on topic. Sorry about
that.

Lorn

Jul 23 '05 #6

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

Similar topics

1
by: jajoo | last post by:
Hi everyone, I am trying to send files with multipart/form-date. Everything is ok with the send. But when I am receiving the files I should specify a directory where the files to be saved. The...
5
by: bart plessers | last post by:
Hello, Currently I am developping a internet "directory browser" My page 'default.asp' has following entries: CurrentPATH = Request("MyLink") Set oFSO =...
2
by: 73blazer | last post by:
Hello, I'm writing some C++ code, and I need to be able to find the number of files in a given directory. Is it possible under AIX4.3.3 with C++ 3.6.4? I cannot seem to locate anything of this...
6
by: Hemant Shah | last post by:
Folks, I need to move HOME directory of an instance to another directory. What is the best way of doing it? Is changing password file enough? or dies DB2 store this info in it's own config? ...
1
by: Mink | last post by:
I have a code that checks a directory to see if it exists, and then if it does not, the code creates the directory and allows the user to add/view files in the directory. Weekly I print a report...
1
by: Earl Teigrob | last post by:
Does someone have or know of an algorythm (method) that will delete all files under a give directory and its subdirectories based on a wildcard mask? I can use this for one directory for each...
11
by: Steve Franks | last post by:
I'm using VS.NET 2005 Beta 2. I have a helper C# class I wrote that I placed in my /App_Code directory. Everything runs fine locally. However when I use the "Copy Web" function to upload the site...
2
by: Rob_S | last post by:
I have a program which saves time stamped files into time stamped directories. When I want to read these files, I get the current date and check for the existence of the directory using.... ...
1
by: dkmarni | last post by:
Hi, I am trying to do this perl script, but not able to complete it successfully. Here is the description what the script has to do.. Accept two and only two command line arguments. Again,...
1
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.