Is there an easy way to copy a folder and all its contents?
Copy a folder
Collapse
X
-
Originally posted by Teqskater View Posti've tried this: File.Copy("AutoPlay\\Adv Duplicator\\*.*", "C:\\Documents and Settings\\Teqskater\\Bureaublad\\Copy", true, true, false, true, nil);
And it didnt work. It has also subfolders with files Btw
I would add _SourceFolder to it to be sure.
Comment
-
-
Now i tryed this code: First a message to check if it is realy the correct path.
and it is. then a statusdialog pops up en goes away in a blink. then no error is displayed. it just doesnt want to copy. the folder has files and subfolders with files. this should be easy but its an issue i have often.
Code:result = Dialog.Message("Notice", _SourceFolder.."AutoPlay\\Adv Duplicator", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); StatusDlg.Show(MB_ICONNONE, false); File.Copy(_SourceFolder.."\\AutoPlay\\Adv Duplicator\\*.*", "C:\\Documents and Settings\\Teqskater\\Bureaublad\\Copy", true, true, false, true, nil); StatusDlg.Hide(); -- Test for error error = Application.GetLastError(); if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); end
Comment
-
-
try this
Code:result = Dialog.Message("Notice", _SourceFolder.."[COLOR="Red"]\\[/COLOR]AutoPlay\\Adv Duplicator", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); StatusDlg.Show(MB_ICONNONE, false); File.Copy(_SourceFolder.."\\AutoPlay\\Adv Duplicator\\*.*", "C:\\Documents and Settings\\Teqskater\\Bureaublad\\Copy", true, true, false, true, nil); StatusDlg.Hide(); -- Test for error error = Application.GetLastError(); if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); end
Embrace change in your life, you never know, it could all work out for the best
Comment
-
-
Originally posted by Teqskater View Postyes i did that multiple times. anyways. thanks for helping me.
when it shows up i can see if the path is correct thats wy i used dailog.message
Good luck on your issue -- please let us know what you discover.
-josh
Comment
-
-
This is my workaround function:
Code:--[[ Explanation: Copy's a folder with al his contents to another location Arguments: from: The source directory to copy from (string) to: The destination directory to copy to (string) ov: overwrite files if a duplicate has bin found (boolean) ab: abort on copy error (boolean) hid: include hidden files (boolean) dlg: show a statusdialog or not (boolean) Created by teqskater ]] function CopyFolder(from, to, ov, ab, hid, dlg) local folders = Folder.Find(from, "*", true, nil); local files = File.Find(from, "*", true, false, nil, nil); -- initialize statusdialog local nfolders = Table.Count(folders); local nfiles = Table.Count(files); local length = nfolders + nfiles; StatusDlg.SetMeterRange(0, length); -- get folders inside the "from" folder only for i, v in folders do folders[i] = String.Replace(folders[i], from, "", true); end -- get files inside the "from" folder only for i, v in files do files[i] = String.Replace(files[i], from, "", true); end -- show statusdialog if dlg == true then StatusDlg.Show(MB_ICONNONE, false); end -- create folders into "to" path for i,v in folders do Folder.Create(to..folders[i]); end -- create files into "to" path for i,v in files do File.Copy(from..files[i], to..files[i], true, ov, ab, hid) end -- hide statusdialog if dlg == true then StatusDlg.Hide(); end end
Code:CopyFolder(_SourceFolder.."\\AutoPlay\\My source folder", _DesktopFolder.."\\My Destination Folder", true, false, true, false);
If you find a bug please post here and i will fix it. I tested the function and ith works for me.
I was much quicker done then i tought . I'm getting pro in AMS. haha.Last edited by Teqskater; 04-02-2008, 09:54 PM.
Comment
-
-
Comment
-
Comment