SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5

Thread: deleting a file

  1. #1
    Member
    Join Date
    Aug 2004
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    deleting a file

    i am using a statement
    rc1=dos_system("del c:\\temp.txt");
    in my program which should delete the file.
    Though during the execution,rc1=0 (i.e successful), its not actually deleting the file or any of its contents.
    Any help?

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    374
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: deleting a file

    the file might be read only, or it is aksing you if you really want to delete the file that winrunner can not see.......anyhow try using the /F switch in the delete command to force the delete......might also need the /Q switch to ensure that it does not ask you if you want it deleting.
    Richard Hunter

  3. #3
    SQA Knight
    Join Date
    Jun 2002
    Location
    Cupertino, CA, USA
    Posts
    2,164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: deleting a file

    If the file is being accessed by another process it can't be deleted. For example, this won't work:

    file_open("c:\\Temp.txt",FO_MODE_WRITE);
    dos_system("del c:\\Temp.txt");

  4. #4
    Senior Member
    Join Date
    May 2001
    Location
    Ankh-Morpork
    Posts
    2,882
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: deleting a file

    Also, note that the return code from dos_system() has nothing to do with the return value(s) from the DOS command it executes. If you want to check it's success, you could try a file_open() after the delete to see if it's still there.
    web site | [url=http://www.ebookworm.us/[/url]

    [i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.</i] (The Song of Roland)

  5. #5
    Member
    Join Date
    Aug 2004
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: deleting a file

    Thanks.It worked. Because I was not closing the file after file_open statement, it was giveing me that error.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:16 AM.

Copyright BetaSoft Inc.