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
  1. Home
  2. Web Development
  3. ASP.NET
  4. File Delete Problem ??

File Delete Problem ??

Scheduled Pinned Locked Moved ASP.NET
helpcsharpsysadminquestion
11 Posts 4 Posters 0 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.
  • A Offline
    A Offline
    Abhi
    wrote on last edited by
    #1

    Hi.. Friends.. When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied." But I can upload new files on server, But I cant delete this files !! I dont know, Why this problem occurred ?? Please, Give me any solution ASAP. Thanks in Advance.

    Regards, Abhi

    S N R 3 Replies Last reply
    0
    • A Abhi

      Hi.. Friends.. When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied." But I can upload new files on server, But I cant delete this files !! I dont know, Why this problem occurred ?? Please, Give me any solution ASAP. Thanks in Advance.

      Regards, Abhi

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      Might be the file is open or in use close that file before trying delete that file

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      A 1 Reply Last reply
      0
      • A Abhi

        Hi.. Friends.. When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied." But I can upload new files on server, But I cant delete this files !! I dont know, Why this problem occurred ?? Please, Give me any solution ASAP. Thanks in Advance.

        Regards, Abhi

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        -- Abhi -- wrote:

        When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied."

        How you are giving file name :confused: ? ASP.NET will be having delete permissions only in the website, Not in all hard disk locations. When referring a path in ASP.NET always use Server.MapPath() to get files physical location on the server.


        My Website | Ask smart questions

        A 1 Reply Last reply
        0
        • S Sandeep Akhare

          Might be the file is open or in use close that file before trying delete that file

          Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

          A Offline
          A Offline
          Abhi
          wrote on last edited by
          #4

          No, Sandeep !! Not any files are open on the server. In my project, I have a admin panel.. With this, I m uploading file, and it uploads successfully... And Then, I m listing all files name and with button 'delete' for each file !! But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !!

          Regards, Abhi

          S 1 Reply Last reply
          0
          • N N a v a n e e t h

            -- Abhi -- wrote:

            When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied."

            How you are giving file name :confused: ? ASP.NET will be having delete permissions only in the website, Not in all hard disk locations. When referring a path in ASP.NET always use Server.MapPath() to get files physical location on the server.


            My Website | Ask smart questions

            A Offline
            A Offline
            Abhi
            wrote on last edited by
            #5

            No, Navneeth !! Not any files are open on the server. In my project, I have a admin panel.. With this, I m uploading file, and it uploads successfully... And Then, I m listing all files name and with button 'delete' for each file !! But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !! Regards, Abhi

            Regards, Abhi

            N 1 Reply Last reply
            0
            • A Abhi

              No, Sandeep !! Not any files are open on the server. In my project, I have a admin panel.. With this, I m uploading file, and it uploads successfully... And Then, I m listing all files name and with button 'delete' for each file !! But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !!

              Regards, Abhi

              S Offline
              S Offline
              Sandeep Akhare
              wrote on last edited by
              #6

              Sorry i gave wrong reply but yo should have read/write/delete permision for that path to asp.net process Do one thing give all permision to Everyone then try if it delete the file then go specific

              Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

              1 Reply Last reply
              0
              • A Abhi

                No, Navneeth !! Not any files are open on the server. In my project, I have a admin panel.. With this, I m uploading file, and it uploads successfully... And Then, I m listing all files name and with button 'delete' for each file !! But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !! Regards, Abhi

                Regards, Abhi

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                -- Abhi -- wrote:

                But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !!

                Well, can you post that deletion code here ?


                My Website | Ask smart questions

                A 1 Reply Last reply
                0
                • N N a v a n e e t h

                  -- Abhi -- wrote:

                  But when, I click on 'delete' button , I am deleting files from server by C# code..Then I got this error !!

                  Well, can you post that deletion code here ?


                  My Website | Ask smart questions

                  A Offline
                  A Offline
                  Abhi
                  wrote on last edited by
                  #8

                  Yes. Sure. System.IO.FileInfo objFileInfo = new System.IO.FileInfo(Server.MapPath("../File/") + Filename.ToString()); System.Security.Permissions.FileIOPermission fp = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, objFileInfo.Directory.FullName); objFileInfo.Delete();

                  Regards, Abhi

                  N 1 Reply Last reply
                  0
                  • A Abhi

                    Yes. Sure. System.IO.FileInfo objFileInfo = new System.IO.FileInfo(Server.MapPath("../File/") + Filename.ToString()); System.Security.Permissions.FileIOPermission fp = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, objFileInfo.Directory.FullName); objFileInfo.Delete();

                    Regards, Abhi

                    N Offline
                    N Offline
                    N a v a n e e t h
                    wrote on last edited by
                    #9

                    -- Abhi -- wrote:

                    Server.MapPath("../File/") + Filename.ToString()

                    Have you printed out put of this line ? Are you getting a valid file path ?

                    -- Abhi -- wrote:

                    System.Security.Permissions.FileIOPermission fp = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, objFileInfo.Directory.FullName); objFileInfo.Delete();

                    Why all these ? Simply call File.Delete(Path)


                    My Website | Ask smart questions

                    A 1 Reply Last reply
                    0
                    • N N a v a n e e t h

                      -- Abhi -- wrote:

                      Server.MapPath("../File/") + Filename.ToString()

                      Have you printed out put of this line ? Are you getting a valid file path ?

                      -- Abhi -- wrote:

                      System.Security.Permissions.FileIOPermission fp = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, objFileInfo.Directory.FullName); objFileInfo.Delete();

                      Why all these ? Simply call File.Delete(Path)


                      My Website | Ask smart questions

                      A Offline
                      A Offline
                      Abhi
                      wrote on last edited by
                      #10

                      Yes... This path works best in my Local project in my machine. But after uploading this project DLL to the server by FTP... Then I got error. I have used below code : System.Security.Permissions.FileIOPermission fp = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, objFileInfo.Directory.FullName); But, I cant find solution with above permission code, this code is meaning less.

                      Regards, Abhi

                      1 Reply Last reply
                      0
                      • A Abhi

                        Hi.. Friends.. When I delete file with C# code, I m getting error like "Access to the path 'g:\activewebroot\Active24\w11618838\web\content\File\xxx.zip' is denied." But I can upload new files on server, But I cant delete this files !! I dont know, Why this problem occurred ?? Please, Give me any solution ASAP. Thanks in Advance.

                        Regards, Abhi

                        R Offline
                        R Offline
                        rashidpervaiz08
                        wrote on last edited by
                        #11

                        If you r writing this code in asp.net, so due to security reason this will not done, u have to use impersonation or check authentication mode. Muhammad Rashid

                        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