CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Posts
    14

    Removing a directory in windows( When a file already opened from that directory)

    Hi,
    I can able to remove the files and sub directories and the diectory also.
    But is it possible to delete a directory when any one of the files of that opend.

    Generally if we try manually to delete a folder, when a file opened from that directory, windows throw an err as " can not delete <dirName> : It is being used by another person or program".

    Can we manage this error in coding and can delete the directoty.
    Please let me know


    Thanks in Advance.

    Sri
    Attached Images Attached Images  

  2. #2
    Join Date
    Jun 2007
    Posts
    29

    Re: Removing a directory in windows( When a file already opened from that directory)

    What's supposed to happen to the open file then? You're talking about messing with operating system functions. No, you can't.

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Removing a directory in windows( When a file already opened from that directory)

    Can we manage this error in coding and can delete the directoty.
    No, that is the system behaviour. When a file is opened, it cannot be deleted, not the folder where it is located.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Removing a directory in windows( When a file already opened from that directory)

    Quote Originally Posted by sri_1221
    Can we manage this error in coding and can delete the directoty.
    As already indicated, you can't do that directly, or else use CloseHandle first to close the file and then delete it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured