Delete(strDirPath, true) gives "the directory is not empty"

Discussion in 'ASP .Net' started by codeboy, Jun 8, 2009.

  1. codeboy

    codeboy Guest

    I am using VS2008 to create a website. When I try to programmatically delete
    a directory that is located within my website I will get an error. I am
    trying to delete the directory using “System.IO.Directory.Delete(strDirPath,
    true)â€. This is the message the error gives "the directory is not empty". I
    found another entry titled “Directory.Delete of a non empty dir fails in
    ASP.NET applicationâ€. In that posting Walter Wang says: “the folder is
    locked by Visual Studio 2005 IDE if the folder is already shown in project
    explorerâ€. Now that I am using VS2008 has this been changed? How can I test
    my code? Please help me get past this problem.

    Thanks
     
    codeboy, Jun 8, 2009
    #1
    1. Advertising

  2. re:
    !> How can I test my code?

    Create an IIS virtual directory and test directory.delete with VS 2008 closed.

    You can undo the IIS virtual directory when you've finished testing directory.delete.

    When done testing directory.delete, open VS 2008 and continue testing the rest of the code.




    Juan T. Llibre, asp.net MVP
    ¿ Estas probando VS 2010 y ASP.NET 4.0 ?
    Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
    http://asp.net.do/foros/forums/
    =====================================================
    "codeboy" <> wrote in message
    news:...
    >I am using VS2008 to create a website. When I try to programmatically delete
    > a directory that is located within my website I will get an error. I am
    > trying to delete the directory using "System.IO.Directory.Delete(strDirPath,
    > true)". This is the message the error gives "the directory is not empty". I
    > found another entry titled "Directory.Delete of a non empty dir fails in
    > ASP.NET application". In that posting Walter Wang says: "the folder is
    > locked by Visual Studio 2005 IDE if the folder is already shown in project
    > explorer". Now that I am using VS2008 has this been changed? How can I test
    > my code? Please help me get past this problem.
    >
    > Thanks
     
    Juan T. Llibre, Jun 8, 2009
    #2
    1. Advertising

  3. codeboy

    codeboy Guest

    This seems like a very cumbersome way of tying to handle the problem. I also
    like to use the debugging tools. They will not be available if VS2008 is
    closed. I need a way of testing my code within the development environment
    without getting this error. How can I do this?

    "Juan T. Llibre" wrote:

    > re:
    > !> How can I test my code?
    >
    > Create an IIS virtual directory and test directory.delete with VS 2008 closed.
    >
    > You can undo the IIS virtual directory when you've finished testing directory.delete.
    >
    > When done testing directory.delete, open VS 2008 and continue testing the rest of the code.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > ¿ Estas probando VS 2010 y ASP.NET 4.0 ?
    > Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
    > http://asp.net.do/foros/forums/
    > =====================================================
    > "codeboy" <> wrote in message
    > news:...
    > >I am using VS2008 to create a website. When I try to programmatically delete
    > > a directory that is located within my website I will get an error. I am
    > > trying to delete the directory using "System.IO.Directory.Delete(strDirPath,
    > > true)". This is the message the error gives "the directory is not empty". I
    > > found another entry titled "Directory.Delete of a non empty dir fails in
    > > ASP.NET application". In that posting Walter Wang says: "the folder is
    > > locked by Visual Studio 2005 IDE if the folder is already shown in project
    > > explorer". Now that I am using VS2008 has this been changed? How can I test
    > > my code? Please help me get past this problem.
    > >
    > > Thanks

    >
    >
    >
    >
     
    codeboy, Jun 8, 2009
    #3
  4. re:
    !> This seems like a very cumbersome way of tying to handle the problem.

    Given that VS 2008 locks the directory, it's the only way to do it.

    re:
    !> I also like to use the debugging tools. They will not be available if VS2008 is closed.

    Of course not, but testing directory.delete doesn't really require a lot of debugging, does it ?
    Do a simple test...and learn the correct way to handle directory deletions in IIS.

    re:
    !> I need a way of testing my code within the development
    !> environment without getting this error. How can I do this?

    File a bug report and wait for it to be fixed.

    Also, you might want to check to see whether any files are in the directory.
    You'll have to delete the files first before deleting the directory.

    Also, are you sure the directory is not set as a read-only directory ?

    See code to do that at :
    http://www.eggheadcafe.com/conversation.aspx?messageid=33335128&threadid=33307218




    Juan T. Llibre, asp.net MVP
    ¿ Estas probando VS 2010 y ASP.NET 4.0 ?
    Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
    http://asp.net.do/foros/forums/
    =====================================================
    "codeboy" <> wrote in message
    news:...
    > This seems like a very cumbersome way of tying to handle the problem. I also
    > like to use the debugging tools. They will not be available if VS2008 is
    > closed. I need a way of testing my code within the development environment
    > without getting this error. How can I do this?
    >
    > "Juan T. Llibre" wrote:
    >
    >> re:
    >> !> How can I test my code?
    >>
    >> Create an IIS virtual directory and test directory.delete with VS 2008 closed.
    >>
    >> You can undo the IIS virtual directory when you've finished testing directory.delete.
    >>
    >> When done testing directory.delete, open VS 2008 and continue testing the rest of the code.
    >>
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> ¿ Estas probando VS 2010 y ASP.NET 4.0 ?
    >> Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
    >> http://asp.net.do/foros/forums/
    >> =====================================================
    >> "codeboy" <> wrote in message
    >> news:...
    >> >I am using VS2008 to create a website. When I try to programmatically delete
    >> > a directory that is located within my website I will get an error. I am
    >> > trying to delete the directory using "System.IO.Directory.Delete(strDirPath,
    >> > true)". This is the message the error gives "the directory is not empty". I
    >> > found another entry titled "Directory.Delete of a non empty dir fails in
    >> > ASP.NET application". In that posting Walter Wang says: "the folder is
    >> > locked by Visual Studio 2005 IDE if the folder is already shown in project
    >> > explorer". Now that I am using VS2008 has this been changed? How can I test
    >> > my code? Please help me get past this problem.
    >> >
    >> > Thanks

    >>
    >>
    >>
    >>
     
    Juan T. Llibre, Jun 8, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Siemel Naran

    Does true ^ true return false?

    Siemel Naran, Jun 17, 2004, in forum: C++
    Replies:
    19
    Views:
    675
    Chris Theis
    Jun 18, 2004
  2. Chip
    Replies:
    6
    Views:
    2,651
    E. Robert Tisdale
    Jan 8, 2005
  3. bdb112
    Replies:
    45
    Views:
    1,373
    jazbees
    Apr 29, 2009
  4. codeboy
    Replies:
    1
    Views:
    1,578
    Juan T. Llibre
    Jun 8, 2009
  5. Pedro Gonçalves

    Subject: impersonate="True" gives login (null) for SQL Server acce

    Pedro Gonçalves, Jun 29, 2006, in forum: ASP .Net Security
    Replies:
    5
    Views:
    194
    Joe Kaplan \(MVP - ADSI\)
    Jun 30, 2006
Loading...

Share This Page