Announcement

Collapse
No announcement yet.

File.Copy produces 0KB files and LastError shows "Aborted by user"

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

  • File.Copy produces 0KB files and LastError shows "Aborted by user"

    Hi. I have a function wich copies a few files from one folder to another and I noticed that most times the file in the destination has 0KB. App.LastError shows "Aborted by User" but I did not abort anything.

    The copy line:
    File.Copy(GAMEFOLDER.."\\GAMEDATA\\PCBANKS"..tblP ath.Filename..tblPath.Extension, GAMEFOLDER.."\\NMSManager\\Mods"..tblPath.Filenam e..tblPath.Extension, false, false, false, true, nil);

    Any idea why it does create 0KB files and say aborted by user? I tried it with and without admin rights (copying in c:\program files).

    the debug window shows this:
    [71]: File.Copy(GAMEFOLDER.."\\GAMEDATA\\PCBANKS"..tblP ath.Filename..tblPath.Extension, GAMEFOLDER.."\\NMSManager\\Mods"..tblPath.Filenam e..tblPath.Extension, false, false, false, true, nil);
    TRACE: LastError = 0 ("Success.")
    TRACE: LastError = 0 ("Success.")
    TRACE: LastError = 0 ("Success.")
    TRACE: LastError = 0 ("Success.")
    TRACE: LastError = 0 ("Success.")
    TRACE: LastError = 1027 ("Operation aborted by user.")
    [72]: error = Application.GetLastError();

    This is the whole loop for the copy process:
    Code:
      -- Get installed Mods
      tblResults = nil;
      tblResults = File.Find(GAMEFOLDER.."\\GAMEDATA\\PCBANKS", "_*.pak", false, false, nil, nil);
      if tblResults ~= nil then
       for i,v in pairs(tblResults) do
        tblPath = nil;
        tblPath = String.SplitPath(v);
        -- Copy installed Mods to manager folder if not already existent
        tblModResult = nil;
        tblModResult = File.Find(GAMEFOLDER.."\\NMSManager\\Mods\\", tblPath.Filename..tblPath.Extension, false, false, nil, nil);
        if tblModResult == nil then
         -- copy mod
         File.Copy(GAMEFOLDER.."\\GAMEDATA\\PCBANKS\\"..tblPath.Filename..tblPath.Extension, GAMEFOLDER.."\\NMSManager\\Mods\\"..tblPath.Filename..tblPath.Extension, false, false, false, true, nil);
         error = Application.GetLastError();
         if (error ~= 0) then
          Dialog.Message("Error #"..error, _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
         end
         -- copy .toc
         File.Copy(GAMEFOLDER.."\\GAMEDATA\\PCBANKS\\"..tblPath.Filename..".toc", GAMEFOLDER.."\\NMSManager\\Mods\\"..tblPath.Filename..".toc", false, false, false, true, nil);
        end
        -- add to Modlist
        Tree.InsertNode("ModsList", (Tree.GetChildCount("ModsList", "0"))+1, {Text=tblPath.Filename,Data=GAMEFOLDER.."\\NMSManager\\Mods\\"..tblPath.Filename..tblPath.Extension,Checked=true});
       end
      end
    when I copy a single file it works fine but in this loop it seems to abort before the copy process is finished?
    I use 8.3.0.0 and the patchnotes mention a fix for File.Copy
    (Fix: Fixed a couple issues in the 'File.Copy' action where the 'AbortOnFail' parameter wasn't working properly, and progress wasn't handled correctly upon failure.)
    Is there still something broken?
    Last edited by Bl4ckSh33p; 08-21-2016, 01:31 PM.
    Bl4ckSh33p-Soft - Custom Software and Indie Games

  • #2
    I may have found the reason for this bug/issue. I added a "Show Status Dialog" action at the start of the function containing this and some other loops/if-then blocks and a Hide Status Dialog at the end of all loops and when I disable it (comment) it seem to work fine without this error. Does the built in status dialog not like to be open for several different actions/loops and Do i have to add it before and after each File.Copy action to work and show progress for the user? Is this a bug?
    Bl4ckSh33p-Soft - Custom Software and Indie Games

    Comment

    Working...
    X