PDA

View Full Version : Find File On Drive(s)


SteevieNiteHeat
10-09-2009, 02:13 PM
I know I can sometimes be a pain in the backside always asking for hep and not always giving back, so I thought I would give back to the community by adding a sample app for a bit of code I needed but couldn't find to fit my requirements.

This is an example to find a file and returns the drive letter the file is stored on.

Edit the app's 'On Click' action and replace Yourfile.here with the file you want, then run it and it will search in the root directory of all drives and display the result in a dialog message, then you could use it how I did, by using the result variable to point to that drive, ie:
writable_path = path_parts.Drive.."\\Tester\\"

I know this is probably out there as general knowledge, but it took me a long time to search & fine tune the script for my needs, and I hope it will be of use to somebody at least! :-)

tbDrives = Drive.Enumerate();
for i,v in tbDrives do
--replace Yourfile.here with the file you wish to find
tbFile = File.Find(v, "Yourfile.here", false, false, nil, nil);
if not tbFile then
else
path_parts = String.SplitPath(tbFile[1]);
Dialog.Message("File found on Drive:", path_parts.Drive.."\\", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
end

sa3eed
12-07-2009, 11:09 PM
thank you frind

aliali
12-27-2009, 05:12 PM
A thousand thanks