View Full Version : Folder browse and import
abnrange
03-20-2009, 10:45 AM
Hello,
In my project I would like to have a button (add file) that on click it will prompt the user to select a file(s) that they would like to import and have that file import to a specific folder (autoplay\\bios) automatically without the end user selecting the destination folder. How can this be done?
Thanks
ShadowUK
03-20-2009, 11:24 AM
Dialog.FileBrowse, File.Copy.
Imagine Programming
03-20-2009, 11:25 AM
This should work.
local tblFiles = Dialog.FileBrowse(true, "Locate File(s)", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", true, false);
if(tblFiles[1]~="CANCEL")then
for i, v in tblFiles do
if(File.DoesExist(v))then
File.Copy(v, _SourceFolder.."\\".."Autoplay\\bios\\", true, true, false, true, nil);
end
end
end
Imagine Programming
03-20-2009, 11:26 AM
Dialog.FileBrowse, File.Copy.
lol you were faster...
abnrange
03-20-2009, 11:59 AM
Thanks - thay works perfectly.
I do have a question about the script - What does i, v (for i, v in tblFiles) mean? I 'm not a programmer and have seen this in other scripts - Just trying to learn and understand. Thanks again.
Imagine Programming
03-20-2009, 01:19 PM
when you type
for i, v in tblFiles do
you loop through all the entries in the table called tblFiles (selected files from open dialog)
and every time i is the variable that has the current index it's working in (table index, could be string or nummeric (or even a entryname/variable name))
and v is it's content (of the current index)
so, when you have
tblLol = {"lmao", "rofl", "lol"}
and you use
for LetsCallThisIndex, LetsCallThisString in tblLol do
Dialog.Message("Test", "Current Entry: "..tostring(LetsCallThisIndex).."\r\nContent:"..LetsCallThisString)
end
So it doesn't matter if it's for i, v in tblName or if it's for Index, Value in tblName (or anything else)
Try it out, the helpfile is also very usefull:)
abnrange
03-20-2009, 02:53 PM
Now I understand!
Thanks for your time and help.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.