Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. delete folder in asp.net 2.0

delete folder in asp.net 2.0

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netsysadmin
9 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    trilokharry
    wrote on last edited by
    #1

    FileInfo file = new FileInfo(Server.MapPath(FilePath)); file.Delete(); above for deleting file path from application this code not working for folder How can I delete particular folder??????

    You get the best out of others when you give the best of yourself.

    G 1 Reply Last reply
    0
    • T trilokharry

      FileInfo file = new FileInfo(Server.MapPath(FilePath)); file.Delete(); above for deleting file path from application this code not working for folder How can I delete particular folder??????

      You get the best out of others when you give the best of yourself.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Use the Directory.Delete method.

      Despite everything, the person most likely to be fooling you next is yourself.

      T 1 Reply Last reply
      0
      • G Guffa

        Use the Directory.Delete method.

        Despite everything, the person most likely to be fooling you next is yourself.

        T Offline
        T Offline
        trilokharry
        wrote on last edited by
        #3

        I used like this Directory.Delete(dirPath,true); but not working please can you give some more clarifications.

        You get the best out of others when you give the best of yourself.

        M T 2 Replies Last reply
        0
        • T trilokharry

          I used like this Directory.Delete(dirPath,true); but not working please can you give some more clarifications.

          You get the best out of others when you give the best of yourself.

          M Offline
          M Offline
          MHASSANF
          wrote on last edited by
          #4

          what's the error ??

          1 Reply Last reply
          0
          • T trilokharry

            I used like this Directory.Delete(dirPath,true); but not working please can you give some more clarifications.

            You get the best out of others when you give the best of yourself.

            T Offline
            T Offline
            trilokharry
            wrote on last edited by
            #5

            dirPath="~/upload/a/1" 1) Exception Information --- Exception Type: System.IO.DirectoryNotFoundException Message: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. Data: System.Collections.ListDictionaryInternal InnerException: NULL TargetSite: Void WinIOError(Int32, System.String) StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive) at System.IO.Directory.Delete(String path, Boolean recursive) at Client_ManageMyFile.gvManageMyFile_RowDeleting(Object sender, GridViewDeleteEventArgs e) in c:\Inetpub\wwwroot\DocumentShare\DocumentShare\Client\ManageMyFile.aspx.cs:line 203 HelpLink: NULL Source: mscorlib Exception Information System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. at System.IO.__Error.WinIOError(Int32 errorCo

            You get the best out of others when you give the best of yourself.

            T G 2 Replies Last reply
            0
            • T trilokharry

              dirPath="~/upload/a/1" 1) Exception Information --- Exception Type: System.IO.DirectoryNotFoundException Message: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. Data: System.Collections.ListDictionaryInternal InnerException: NULL TargetSite: Void WinIOError(Int32, System.String) StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive) at System.IO.Directory.Delete(String path, Boolean recursive) at Client_ManageMyFile.gvManageMyFile_RowDeleting(Object sender, GridViewDeleteEventArgs e) in c:\Inetpub\wwwroot\DocumentShare\DocumentShare\Client\ManageMyFile.aspx.cs:line 203 HelpLink: NULL Source: mscorlib Exception Information System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. at System.IO.__Error.WinIOError(Int32 errorCo

              You get the best out of others when you give the best of yourself.

              T Offline
              T Offline
              trilokharry
              wrote on last edited by
              #6

              I want to delete hari folder with files dirPath="~/upload/a/hari" I used like this Directory.Delete(dirPath,true); but not working error description using Directory.Delete(dirPath,true): 1) Exception Information --- Exception Type: System.IO.DirectoryNotFoundException Message: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. Data: System.Collections.ListDictionaryInternal InnerException: NULL TargetSite: Void WinIOError(Int32, System.String) StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive) at System.IO.Directory.Delete(String path, Boolean recursive) at Client_ManageMyFile.gvManageMyFile_RowDeleting(Object sender, GridViewDeleteEventArgs e) in c:\Inetpub\wwwroot\DocumentShare\DocumentShare\Client\ManageMyFile.aspx.cs:line 203 HelpLink: NULL Source: mscorlib Exception Information System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. at System.IO.__Error.WinIOError(Int32 errorCo

              You get the best out of others when you give the best of yourself.

              1 Reply Last reply
              0
              • T trilokharry

                dirPath="~/upload/a/1" 1) Exception Information --- Exception Type: System.IO.DirectoryNotFoundException Message: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. Data: System.Collections.ListDictionaryInternal InnerException: NULL TargetSite: Void WinIOError(Int32, System.String) StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive) at System.IO.Directory.Delete(String path, Boolean recursive) at Client_ManageMyFile.gvManageMyFile_RowDeleting(Object sender, GridViewDeleteEventArgs e) in c:\Inetpub\wwwroot\DocumentShare\DocumentShare\Client\ManageMyFile.aspx.cs:line 203 HelpLink: NULL Source: mscorlib Exception Information System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\~\upload\a\1'. at System.IO.__Error.WinIOError(Int32 errorCo

                You get the best out of others when you give the best of yourself.

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                You are trying to use a virtual path with a file system method. The Delete method can not determine what this path is supposed to mean, as it's not aware of the web application. Even if it could determine that the path is supposed to be a virtual path, it doesn't have any information about the web application so that it could determine where the root folder of the application is. You have to convert the virtual path into a physical path using the MapPath method.

                Despite everything, the person most likely to be fooling you next is yourself.

                T 1 Reply Last reply
                0
                • G Guffa

                  You are trying to use a virtual path with a file system method. The Delete method can not determine what this path is supposed to mean, as it's not aware of the web application. Even if it could determine that the path is supposed to be a virtual path, it doesn't have any information about the web application so that it could determine where the root folder of the application is. You have to convert the virtual path into a physical path using the MapPath method.

                  Despite everything, the person most likely to be fooling you next is yourself.

                  T Offline
                  T Offline
                  trilokharry
                  wrote on last edited by
                  #8

                  I want to delete only hari folder with files after map path string Path = ~/upload/hari Directory.Delete(Server.MapPath(Path).ToString(), true); but not working please help me Server.MapPath(Path).ToString() is below MapPath="C:\Inetpub\wwwroot\DocumentShare\DocumentShare\upload\hari" thanks for your kind response

                  You get the best out of others when you give the best of yourself.

                  G 1 Reply Last reply
                  0
                  • T trilokharry

                    I want to delete only hari folder with files after map path string Path = ~/upload/hari Directory.Delete(Server.MapPath(Path).ToString(), true); but not working please help me Server.MapPath(Path).ToString() is below MapPath="C:\Inetpub\wwwroot\DocumentShare\DocumentShare\upload\hari" thanks for your kind response

                    You get the best out of others when you give the best of yourself.

                    G Offline
                    G Offline
                    Guffa
                    wrote on last edited by
                    #9

                    trilokharry wrote:

                    but not working

                    If you would be a bit more specific, it might be possible to help you. What happens? Do you get an error message?

                    Despite everything, the person most likely to be fooling you next is yourself.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups