Announcement

Collapse
No announcement yet.

Folder Does Exist, File Copy code check please

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

  • nitrobry
    replied
    Hi All
    Thanks for the help

    This has now been fixed. I used this code

    Code:
    if not Folder.DoesExist("C:\\My Games")then
      Folder.Create("C:\\My Games");
    end
    File.Copy("\\AutoPlay\\Docs\\GameList.db", "C:\\My Games", true, true, false, true, nil);

    Leave a comment:


  • kingzooly
    replied
    Also make a check the file is in the folder before coping

    Leave a comment:


  • Shrek
    replied
    Code:
    -- Check to see if a specific folder exists.
    if Folder.DoesExist("C:\\My Games") then
      File.Copy("AutoPlay\\Docs\\GameList.db", "C:\\My Games", true, true, false, true, nil);
      local err = Application.GetLastError()
      if (err ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[err].."\r\n".."AutoPlay\\Docs\\GameList.db", MB_OK, MB_ICONEXCLAMATION);
      end
    else
     Folder.Create("C:\\My Games");
    end
    try the _SourceFolder variable instead if that don't work.

    Leave a comment:


  • nitrobry
    replied
    Thanks Shrek
    Is this how it goes for the application get last error
    because it creates the folder but no file added

    Code:
    -- Check to see if a specific folder exists.
    if Folder.DoesExist("C:\\My Games") then
      File.Copy("\\AutoPlay\\Docs\\GameList.db", "C:\\My Games", true, true, false, true, nil);
    else
     Folder.Create("C:\\My Games");
    end
    
    
    --Check to see if an error occurred.
    error = Application.GetLastError();
    
    -- If an error occurred, display the error message.
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    end

    Leave a comment:


  • Shrek
    replied
    "\\AutoPlay\\Docs\\GameList.db" should be "AutoPlay\\Docs\\GameList.db" but do use application get last error as it would tell you the file does not exist.

    Leave a comment:


  • nitrobry
    started a topic Folder Does Exist, File Copy code check please

    Folder Does Exist, File Copy code check please

    Hi All
    Can someone check my code please
    I want to add a folder and a file if exist's.
    The code below Creates a folder but don't copy the file to that folder, the folder is empty.

    The GameList.db file is located at Autoplay Docs.


    Code:
    if Folder.DoesExist("C:\\My Games") then
      File.Copy("\\AutoPlay\\Docs\\GameList.db", "C:\\My Games", true, true, false, true, nil);
    else
     Folder.Create("C:\\My Games");
    end
Working...
X