Bruce
08-20-2005, 12:53 PM
I'm trying to copy all the files from my project CD to the user’s hard drive. This is the code I am using:
==ON CLICK==
--get the destination folder
sDestFolder = Dialog.FolderBrowse("Select the Destination Folder", _DesktopFolder)
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder(_SourceFolder, sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end
==GLOBAL==
function CopyFolder(sSource, sDestination)
local m_sFolder;
local m_FoundFolder;
local error;
--Find all the folders and sub-Folders
--results are stored in the table m_tblFolders
m_tblFolders = Folder.Find(sSource, "*", true, nil);
--if our destination folder does not have the
--backslash as the last character, add it
if String.Right(sDestination, 1) ~= "\\" then
sDestination = sDestination .. "\\";
end
--m_tblFolders will be nil if there are no folders
if m_tblFolders ~= nil then
--enumerate through the found folders
for n, m_FoundFolder in m_tblFolders do
--replace the source's path with the destination's path
m_sFolder = String.Replace(m_FoundFolder, sSource, sDestination, false);
--create the folder
Folder.Create(m_sFolder);
error = Application.GetLastError();
if (error ~= 0) then
--set n to value to exit FOR loop
n = Table.Count(m_tblFolders)
end
end
end
--if no errors occurred, copy the files
if (error == 0) then
--show the status dialog
StatusDlg.Show(MB_ICONNONE, false);
--copy all files from the source folder, with recurse.
File.Copy(sSource .. "\\*.*", sDestination, true, true, false, true, nil);
--hide the status dialog
StatusDlg.Hide();
error = Application.GetLastError();
end
--clean up
m_tblFolders = nil;
return error;
end
Not all the files want to be copied including the AutoPlay.exe :huh
==ON CLICK==
--get the destination folder
sDestFolder = Dialog.FolderBrowse("Select the Destination Folder", _DesktopFolder)
--see if the user cancelled
if sDestFolder ~= "CANCEL" then
--initiate the copy
--CopyFolder is function in the Global Functions area of the project (Alt-D-F)
if CopyFolder(_SourceFolder, sDestFolder) == 0 then
result = Dialog.Message("Folder Copy", "The folder has been successfully copied!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
result = Dialog.Message("Folder Copy", "There was an error copying the folder.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
end
end
==GLOBAL==
function CopyFolder(sSource, sDestination)
local m_sFolder;
local m_FoundFolder;
local error;
--Find all the folders and sub-Folders
--results are stored in the table m_tblFolders
m_tblFolders = Folder.Find(sSource, "*", true, nil);
--if our destination folder does not have the
--backslash as the last character, add it
if String.Right(sDestination, 1) ~= "\\" then
sDestination = sDestination .. "\\";
end
--m_tblFolders will be nil if there are no folders
if m_tblFolders ~= nil then
--enumerate through the found folders
for n, m_FoundFolder in m_tblFolders do
--replace the source's path with the destination's path
m_sFolder = String.Replace(m_FoundFolder, sSource, sDestination, false);
--create the folder
Folder.Create(m_sFolder);
error = Application.GetLastError();
if (error ~= 0) then
--set n to value to exit FOR loop
n = Table.Count(m_tblFolders)
end
end
end
--if no errors occurred, copy the files
if (error == 0) then
--show the status dialog
StatusDlg.Show(MB_ICONNONE, false);
--copy all files from the source folder, with recurse.
File.Copy(sSource .. "\\*.*", sDestination, true, true, false, true, nil);
--hide the status dialog
StatusDlg.Hide();
error = Application.GetLastError();
end
--clean up
m_tblFolders = nil;
return error;
end
Not all the files want to be copied including the AutoPlay.exe :huh