PDA

View Full Version : how to detect is FolderBrowse cancaled



reteset
05-27-2006, 02:19 PM
hi all

i.m working on a simple app.
its only copy files from X folder to Y folder
i want to detect if user has click Cancel or Ok button on folder dialog,
i want to do if user has click on Cancel button

show message " copy canceled "
do nothing

and if user has select a folder and click Ok button

copy files from X folder to selected folder
show message " save completed"

i tried this code but its failed on messages
when canceled nothing was saved but my app. say "save complete"
how to resolve this issue

here is similar code of mine


folder = Dialog.FolderBrowse("Open Folder", "C:\\\\");

if folder == "" then
show_message " copy canceled " do nothing
else
copy files from X folder to selected folder
show message " save completed"
end

thanks.

Wonderboy
05-27-2006, 03:07 PM
let`s Asume you have a test file in root C: called TestFile.txt like this C:\TestFile.txt then you could use this to chosse witch folder to copy this test file to, when folder has been decided and accepted a message will appear asking if user wants to cancel or if the user wants to continue and copy the file to this folder, if user would press ok then file will be copyd to this directory, if user press cancel the file wont be copyd and the script will end.


TargetFolder = Dialog.FolderBrowse("Please select a folder:", _DesktopFolder.."\\");
result = Dialog.Message("Notice", "Your message here.", MB_OKCANCEL, MB_ICONINFORMATION, MB_DEFBUTTON1);
if (result == IDOK) then
File.Copy("C:\\TestFile.txt",TargetFolder.."", true, true, false, true, nil);
result = Dialog.Message("Notice", "Your message here.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
end

jcarmony
07-20-2006, 04:36 AM
if cancelled folder = "CANCEL" .......


folder = Dialog.FolderBrowse("Open Folder", "C:\\\\");

if folder == "CANCEL" then
show_message " copy canceled " do nothing
else
copy files from X folder to selected folder
show message " save completed"
end