Forum Discussion

matt's avatar
matt
Occasional Contributor
15 years ago

aqFileSystem.CopyFile displays message box instead of just returning FALSE

If the PathToExistingFile is not found (because it is invalid) then a message box is incorrectly displayed:



Error Copying File or Folder

Cannot copy file: Cannot read from the source file or disk.

[OK]




This causes script execution to hang indefinitely until the message box is manually dismissed. According to the TC online help:




"If the PathToExistingFile file was not found, the method returns False."





It appears to be a defect that a message box is being displayed.




I am seeing this in TC 7.2 and TC 7.5. I don't know about earlier versions.

6 Replies

  • Hello Matt



    I tried to recreate the scenario with



    Sub Test

      Result = aqFileSystem.CopyFile("D:\Sand Pit\trial.txt", "D:\", False)

      Result = aqFileSystem.CopyFile("D:\NonexistingFolder\trial.txt", "D:\", False)

      Result = aqFileSystem.CopyFile("junk", "D:\", False)

    End Sub

     

    All the time I received correct results - True, False and False.



    May be you need to provide some more info about what you are trying to do and a part of the script. Also I suspect if the msgbox is being displayed by TC or the OS.



    Thankyou

    Syed

    www.proteans.com
  • matt's avatar
    matt
    Occasional Contributor
    In my case the PathToExistingFile is a non-existing UNC path:



    \\someserver\someshare\somefolder\folderdoesnotexist\somefile.txt




  • Hi Matt,




    We have failed to reproduce the problem on our side. To investigate it, could you please send us the exact script that you are using for copying via our Contact Support Form (http://www.automatedqa.com/support/message/). Also, please send us a screenshot of the error. Besides that, please make sure that you have needed permissions to get access to the 'someshare' and 'somefolder' directories.

  • matt's avatar
    matt
    Occasional Contributor
    All text from the screen shot is in my original message (title, message, button text) and permissions are not the problem. After more investigation on my part, it appears the problem happens on Windows Server 2003 and does NOT happen on Windows XP. Here is the script:



    function foo()

    {

      aqFileSystem.CopyFile("c:\\doesnotexist\\test.txt", "c:\\test.txt");

    }




    Run this, and the message box will appear on Windows Server 2003.

  • Hi Matt,




    We have reproduced the problem, and we will try to fix it. Currently, you can use the Exists method to check whether a file or a folder exists before copying. Please refer to the "aqFileSystem.Exists" help topic for more information.

  • matt's avatar
    matt
    Occasional Contributor
    Thanks! That is the workaround I had in mind.