Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding file name

Status
Not open for further replies.

Sherak

Programmer
Sep 1, 2003
83
GB
Finding file

I am writing a program to monitor a directory and when a file appears in it, I need to check if the file is in use and if it isnt I need to change its extention.

the files name can be differnt though so how do I check if the file is in use if I dont know its name?

Thanks
 
1; scan directory, make list
2; loop
1; scan directory, make second list
2; compare second list to first list
3; if file is on second list and not on first
the file is new and now you have a filename.
4; add new name to first list


tomcruz.net
 
OR

1; scan directory, check file ext
2; if file extension on one of the files is not
what you are changing them too, it is a new file.
3; you now have a file name to work with

tomcruz.net
 
Thanks for that, I dont need it to be that complicated though as there will not be many files in the directory, there may be none, so I lookin ghte directory if there is a file I change its extention and move it, what I needed to know though was the syntax for getting the file name, I know what your sayign about scaning the directory and making hte list however I dont know the syntax to be able to do it, so basically I want to see if there is a file in the folder, if there is I want to see if it is still in use and if it isnt I want to change its extention and move it, however I cant do this without the file name and it is the instructions to get this name which I need..

thanks
 
See if these instructions help:
BTW, C++ Builder Developers Journal has a lot a good articles. Most are publically available but some are only available for subscribers.

Worth the $$$ IMHO.

James P. Cottingham
-----------------------------------------
To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.
 
You could just use a file list box and refresh it
periodically. if there is anything listed in it you just
rename and move what is listed in there. you get the file
name from the listbox. the list box could even be made
not visible if you want to hide that part of the operation.

bottom line is your probably going to have to write a few
lines of code. you should do some error checking to check to see if the file you are accessing has already been renamed among other things.

once you have the code bullet proof make a cpp and a header file and put your code in there. now you have an addition to your personnall libraary that you can reuse when necessary.

you have started your own personal libray havent you.

maybe not too exotic but the code is traightforward

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top