Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 4 of 4

Thread: Patch

  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Talking Patch

    What is the code for finding a file and paste another file beside it ?

  2. #2
    Join Date
    Apr 2005
    Location
    In Wonderworld
    Posts
    246
    You mean you want to search for a file, example "my file.txt" and see if this file is found and when this file is found you want to place another file into the same folder as where this file is at?

  3. #3
    Join Date
    Apr 2005
    Location
    In Wonderworld
    Posts
    246
    Try this code, this code searches for a file called TestFile on all hard drives,
    and ones this file is found it checks to see if the file is in use and if the size in bytes of the file is equel to what i wanted it to be,and if it is it will be replaced with a file from the docs folder, witch is in a ziped file, you could use this and make some small changes to it,
    Code:
    function DoIfFileFound(sFile)
    	--check to see if the file is in use if not then proceed with the check
    	if not File.IsInUse(sFile) then
    		-- Check the file size, this will need to be customized for your application
    		if File.GetSize(sFile) == 40 then
    			--if it is a match then you can ask your question about overwritting.
    			result = Dialog.Message("Overwrite", "Do you want to overwrite the file:\r\n"..sFile, MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1);
    			if result == IDYES then
    				local tbSplit = String.SplitPath(sFile);
    				Zip.Extract("AutoPlay\\Docs\\file.zip", {"*.*"}, tbSplit.Drive..tbSplit.Folder, false, false, "", ZIP_OVERWRITE_ALWAYS, nil);
    				nErr = Application.GetLastError()
    				if nErr ~= 0 then
    					Dialog.Message("Error", "There was an error replacing the file \r\n\r\n"..sFile.."\r\n\r\nThe error was ".._tblErrorMessages[nErr]);
    				else
    					Dialog.Message("Success", "The file was successfully replaced");
    				 File.Delete("AutoPlay\\Docs\\Dummyfolder\\DummyFile.txt", false, false, false, nil);
                    end
    				return false;
    			else
    				--set to true to continue search
    				return false;
    			end
    		else
    			--set to true to continue searching.
    			return false;
    		end
    	end
    end
    
    --This code executes the find
    --find all the drives present in the system
    tbDrives = Drive.Enumerate();
    for i,v in tbDrives do
    	--if the drive is a fixed hard drive then look for the file
    	if Drive.GetType(v) == DRIVE_FIXED then
    		-- if the file is found this line will execute the DoIfFileFound function which is described above.
    		tbFile = File.Find(v, "*TestFile*.*", true, false, nil, DoIfFileFound);
    		if not tbFile then
    			bNotFound = true
           end
    	end
    end
    
    if bNotFound then
    file_exist = File.DoesExist("AutoPlay\\Docs\\Dummyfolder\\DummyFile.txt", false, false, false, nil);
    if file_exist == true then
    result = Dialog.Message("File not found", "the file was not found.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else
    end
    end
    This nice code was provided to me by one of the great members on this forum, TJ_Tigger, and with some smal changes by myself so that it would fit me needs
    Last edited by Wonderboy; 04-12-2006 at 07:44 AM.

  4. #4
    Join Date
    Oct 2005
    Posts
    32

    Tnx

    First of all thank you very much for your code , then i want to it search for a file for example (winRAR.exe) to find out where it installed . after that paste my file for example (reg.txt) to the same folder .

Similar Threads

  1. Key Features of Visual Patch 2.0
    By Ted Sullivan in forum Visual Patch 2.0
    Replies: 0
    Last Post: 04-08-2005, 02:56 PM
  2. What's New in Visual Patch 2.0?
    By Ted Sullivan in forum Visual Patch 2.0
    Replies: 0
    Last Post: 04-08-2005, 02:53 PM
  3. Frequently Asked Questions
    By Ted Sullivan in forum Visual Patch 2.0
    Replies: 0
    Last Post: 04-08-2005, 02:49 PM
  4. What is Visual Patch 2.0?
    By Ted Sullivan in forum Visual Patch 2.0
    Replies: 0
    Last Post: 04-08-2005, 02:45 PM
  5. Visual Patch 1.0 Documentation
    By Ted Sullivan in forum Visual Patch 1.0
    Replies: 0
    Last Post: 11-18-2003, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts