Forum Discussion

Bouzouki's avatar
Bouzouki
Occasional Contributor
3 years ago
Solved

Files.Remove in Javascript

Hello All, 

 

First time here. I am studying the Udemy course currently. Very excited to learn as much as I can about Test Complete.

 

I have a question about Files.Remove. The screenshot below provides most of the question.  I have to be doing something elementary incorrect, but I am not seeing it.  Files.NameByFileName does not return the file, but the path is correct. It exists in the specified location, and it does exist in the store too.

I am simply trying to remove the file from the Stores, then I was going to add a different version of the same file.

 

Does my mistake jump out at anyone?

Thank you so much, 

 

Bouzouki

 

 

 

 

  • I would display the values for StoredFilePath and NewFilePath to make sure that you have what you expect.  Perhaps filepath is not being passed the way you think.

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I would display the values for StoredFilePath and NewFilePath to make sure that you have what you expect.  Perhaps filepath is not being passed the way you think.

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you Marsha, great thinking!

       

      Bouzouki does the advice help? 

      • Bouzouki's avatar
        Bouzouki
        Occasional Contributor

        Sorry it took me so long to respond.  When I got the Store Files Count from outside the for loop (decrementing the total file count until no files existed) it would get 'about' half through the files and fail with an index out of bounds error. Meaning if I had 330 Stored Files then it would get to 165 give or take a few and fail.

         

        If I got the file count from within the for loop, then I was able to remove each store file index = to the Count. This hasn't given me an error yet.

         

        I never did figure out why I was having index out of bounds errors, but the solution I came up with works reliably, even though it's not the way I'd write code normally.

         

        Thanks!