Forum Discussion

joffre's avatar
joffre
Regular Contributor
14 years ago

Rename Folders/Subfolders/Files and other doubt

Hi all.


I'm trying to make a function that do exactly what the function attached is doing;

But I want something that uses TestComplete classes instead of CommandPrompt.


I've already read about aq.FileSystem.RenameFolder and RenameFile, but it doesn't seems to be the best way to do that.


Hope someone can help me (again).


------


The other doubt is a little more complex.


I need to open EVERY RENAMED FILE, search for the line "CREATE TABLE xxxxx" and/or "ALTER TABLE xxxxx", and create a new notepad file with all the occurrences, replacing the CREATE TABLE and/or ALTER TABLE for "SELECT * FROM xxxx".


------


Ideas??!?

50 Replies

  • joffre's avatar
    joffre
    Regular Contributor
    Are any of the files in that folder open and in use, as in your SQL Query editor or in a Text file editor?  Are any of the files left in an open state from TestComplete's access (after you call aqFile.OpenTextFile you should close the file)?




    On the folder that I've just created there is no file inside of it. And any folder either.


    Just one folder named "SQL Server" inside C:\


    I try to rename it to "SQLServer" and it doesn't work.


    Call aqFileSystem.RenameFolder("C:\SQL Server", "C:\SQLServer")




    It creates a new folder named SQLServer and pastes the folder SQL Server inside of it.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The only difference between your environment and my environment is that I'm using TestComplete 8.50 and you're using 7.52.  So, I loaded up TC 7.52 and tried it.  I get a clean result in that the folder is renamed and there is nothing copied to any other folders.



    When you're putting the code up, are you doing a direct copy and paste from TestComplete or are you typing it in?  The reason I ask is that the behavior you are describing would happen if you are doing the following:



    Call aqFileSystem.RenameFolder("C:\SQL Server\", "C:\SQLServer")




    Note the backslash (\) in the first path.  This tells RenameFolder to actually move the folder to the destination folder which is the behavior you are describing.



    Examine your code for extraneous backslash characters and remove them.



    Other than that, I'm not sure what else to tell you.  You could try uploading the actual script code unit you are using and I can examine your code directly that way but the function, for me, is working correctly both in TC 8 and in TC 7.
  • joffre's avatar
    joffre
    Regular Contributor
    Call aqFileSystem.RenameFolder("C:\SQL Server", "C:\SQLServer")




    Still not working. No backslash and doesn't work. Still pasting the "SQL Server" (oldpath) folder into "SQLServer" (newpath).
  • Hi,



    I'll try to reproduce this behavior and post here my results.
  • joffre's avatar
    joffre
    Regular Contributor
    Thanks for your help.



    Hope you find the problem.
  • Hi,



    I was able to reproduce this behavior in TC 7.52, however, RenameFolder works correctly in TC 8. I recommend that you install the latest update (8.50) if possible.
  • joffre's avatar
    joffre
    Regular Contributor

    Hi,

    I was able to reproduce this behavior in TC 7.52, however, RenameFolder works correctly in TC 8. I recommend that you install the latest update (8.50) if possible.


    Is it possible to update my version 7.52 to 8.50 without buying the software again? (I don't think so)...

    Is there any way that I can fix it on version 7.52?

    Thanks for your reply.

  • Hi,



    Can you submit a support case to us regarding this and specify your customer ID so that we can check what options are possible?
  • joffre's avatar
    joffre
    Regular Contributor
    Hi,



    Can you submit a support case to us regarding this and specify your customer ID so that we can check what options are possible?





    Support case submitted. Thanks for your help.