Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello,

I am trying to figure out how to create code for my work. We need something that can look through the entire computer and look for a specific file and then open up said file and look for a specific IP Address. Once it finds that Address we would want it to re-write the address with a new one. I figured that maybe this would have to be a loop but I do not know programming very well. I only figured out how to do it with a single text document, not with the entire computer.

Thanks
Posted

1 solution

Warning: traversing the entire directory structure of a hard drive can take quite a long time! Narrow down your search to only the most likely folders to save time.

To look through every folder on a machine, you'd have to implement a recursive function that deals with folder paths. Start the function with the root folder path to start looking at, such as "C:\". The first thing this function should do is call another function to process all the files in the current directory. If the file was found, great, your done! This is your bail-out flag.

If not, get all the subdirectories of the directory you're looking in. Loop through all of these directories and, one at a time, build the new path with the current folderpath and the subdirectory name. The function then calls itself with the new path. This is "recursion".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900