Andromo - Start Making Apps - Free Signup

Announcement

Collapse
No announcement yet.

copy the hole CD to HDD

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • copy the hole CD to HDD

    Hi
    i need help for the coding of copy the entire CD to a harddisk folder.

    How to create a folder i know. To copy the hole stuff i need following code

    ======================================

    endpfad = Input.GetText("pfad");

    Folder.Create( endpfad );

    StatusDlg.Show(MB_ICONNONE, false);
    File.Copy(_SourceDrive .. "\\*.*", endpfad, true, true, false, true, nil);
    --Shell.CreateShortcut(_DesktopFolder, "Ich hab's! Café", endpfad "\\start.exe", "", "", endpfad"\\cafe.ico", 0, SW_MAXIMIZE, nil);
    error = Application.GetLastError();

    -- If an error occurred, display the error code message.
    if (error ~= 0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
    Dialog.Message("Der kopiervorgang ist beendet.", "Ein Icon wurde auf dem Desktop angelegt.", MB_OK, MB_ICONINFORMATION);
    end

    =============================================

    endpfad ist the path the folder. The problem is, that the copy process starts but it is canceld after a few files.

    Can anyone help me

    thanks

    Chris

  • #2
    If you have folders on the CD, the File.Copy action DOES NOT create them for you. You need to manually create the Folder structure on the HD before initiating the File.Copy.

    Somewhere, I have a DLL that will copy a Folder and all its items, I haven't tested it with AMS5, but it would certainly make this process a lot easier. If you're interested, I'll look into whether it works well with AMS5. I truly don't know why it wouldn't.

    Comment


    • #3
      Works great in AM5 as well Worm!
      Regards,

      -Ron

      Music | Video | Pictures

      Comment


      • #4
        Good to hear.

        I probably should throw together an example app sometime. The escape sequences to get the quotes in the parameters can sometimes be a little tricky.

        Comment


        • #5
          No need.

          pixel-kraft, you'll have to do a little reading, but all the info that Worm supplied is right here - enjoy! It works perfect and includes all sub-folders and files.

          http://www.indigorose.com/forums/sho...&threadid=6402
          Regards,

          -Ron

          Music | Video | Pictures

          Comment


          • #6
            Yeah - great DLL
            Thanks for your help Worm.

            But why wait the cool guys from IndigoRose to implement the action into AMS ??? I can copy files with *.* and other wildcards but i can't copy a hole folder with subfolder. I can't understand it. Is that logic?
            Ok, maybe in Ver. 6.0 or later.

            Stay tuned

            Chris
            www.pixel-kraft.de

            Comment


            • #7
              Thanks, glad it worked for you.

              Comment


              • #8
                Here's a way to do this in AMS5 using a Global Function. Personally I think its a better solution than the DLL.

                Here's an example call to copy the entire D: drive to a folder on the C:\Program Files\My App folder.

                Code:
                if CopyFolder("D:\\", "C:\\Program Files\\My App") == 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
                Here's the Global Function:
                Code:
                function CopyFolder(sSource, sDestination)
                	local m_sFolders;
                	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
                	
                		--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
                	end
                	--clean up
                	m_tblFolders = nil;
                	return error;
                end
                Last edited by Worm; 03-04-2004, 01:23 PM.

                Comment


                • #9
                  Here's a little add-on to reset the read-only to false for the above code.

                  Change the call to:
                  Code:
                  if CopyFolder("D:\\", "C:\\Program Files\\My App") == 0 then
                  	UndoReadOnly("C:\\Program Files\MyApp");
                  	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
                  Code:
                  function UndoReadOnly(sFolder)
                  	local n;
                  	local m_File;
                  
                  	--find all the files in the source folder
                  	m_tblFiles = File.Find(sFolder, "*.*", true, true, nil)
                  	
                  	if m_tblFiles ~= nil then
                  		--set up the table of attributes
                  		attrib = {};
                  		attrib.ReadOnly = false;
                  		--enumerate through the found files
                  		for n, m_File in m_tblFiles do
                  			--apply attribute settings
                  			File.SetAttributes(m_File, attrib);
                  		end
                  	end
                  	
                  	--clean up
                  	m_tblFiles = nil;
                  	attrib = nil;
                  end

                  Comment

                  Working...
                  X