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.Copy problem in Windows 2003

File.Copy problem in Windows 2003

Scheduled Pinned Locked Moved ASP.NET
helpsysadminquestion
7 Posts 3 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.
  • L Offline
    L Offline
    larbo204
    wrote on last edited by
    #1

    ..... String fromStr = @"Mymapp\origin.txt"; String txtFile = @"C:\Inetpub\wwwroot\newFile.txt"; File.Delete(txtFile); File.Copy(fromStr, txtFile); ...... This works fine on Windows XP. It WORKED fine on Windows 2003 some days ago, but suddenly it stopped working on Windows 2003. I get something like (in swedish) "Access to the path C:\Inetpub\wwwroot\newFile.txt denied" I have given all rights to 'NETWORK SERVICE' but it doesn't help. It removes 'txtFile' which it should do, but it doesn't create a new one. Any ideas?

    M 1 Reply Last reply
    0
    • L larbo204

      ..... String fromStr = @"Mymapp\origin.txt"; String txtFile = @"C:\Inetpub\wwwroot\newFile.txt"; File.Delete(txtFile); File.Copy(fromStr, txtFile); ...... This works fine on Windows XP. It WORKED fine on Windows 2003 some days ago, but suddenly it stopped working on Windows 2003. I get something like (in swedish) "Access to the path C:\Inetpub\wwwroot\newFile.txt denied" I have given all rights to 'NETWORK SERVICE' but it doesn't help. It removes 'txtFile' which it should do, but it doesn't create a new one. Any ideas?

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Did the privileges on the folder (c:\inetpub\wwwroot) change?

      L 1 Reply Last reply
      0
      • M Mike Ellison

        Did the privileges on the folder (c:\inetpub\wwwroot) change?

        L Offline
        L Offline
        larbo204
        wrote on last edited by
        #3

        I simplified the code before. It should more be like this: String strFile = @"C:\Documents and Settings\Administrator\Application Data\aFolder\anotherFolder\readFrom file.xxx"; String txtFile = @"C:\Inetpub\wwwroot\theWebFolder\textfiles\textFile.txt"; File.Delete(txtFile); File.Copy(strFile, txtFile); The folder 'textfiles' still has all rights it needs. I deleted it, created a new one, gave it all rights but it didn't help. So I tried to add in the web.config file and then it worked!!! BUT I have to log in via a Windows log in form. So I changed to but then I got "Server Error in '/traderamail' Application........ This tag should then have its "mode" attribute set to "Off"."... though I have set . Still I wonder why it work on XP and not on Windows 2003.

        M 1 Reply Last reply
        0
        • L larbo204

          I simplified the code before. It should more be like this: String strFile = @"C:\Documents and Settings\Administrator\Application Data\aFolder\anotherFolder\readFrom file.xxx"; String txtFile = @"C:\Inetpub\wwwroot\theWebFolder\textfiles\textFile.txt"; File.Delete(txtFile); File.Copy(strFile, txtFile); The folder 'textfiles' still has all rights it needs. I deleted it, created a new one, gave it all rights but it didn't help. So I tried to add in the web.config file and then it worked!!! BUT I have to log in via a Windows log in form. So I changed to but then I got "Server Error in '/traderamail' Application........ This tag should then have its "mode" attribute set to "Off"."... though I have set . Still I wonder why it work on XP and not on Windows 2003.

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Okay, I would think that if it worked when you turned on identity impersonation, then you are definitely dealing with a permissions issue. The Windows login that you used had all necessary privileges to the files and folder to perform the delete and copy. If impersonation is turned off, then the ASPNET user account would have to have the proper permissions to the files and folder.

          L 1 Reply Last reply
          0
          • M Mike Ellison

            Okay, I would think that if it worked when you turned on identity impersonation, then you are definitely dealing with a permissions issue. The Windows login that you used had all necessary privileges to the files and folder to perform the delete and copy. If impersonation is turned off, then the ASPNET user account would have to have the proper permissions to the files and folder.

            L Offline
            L Offline
            larbo204
            wrote on last edited by
            #5

            Ok. But what more can I do than to give NETWORK SERVICE all rights it should need? I tried to give it to ASPNET but that works for Windows XP, not Windows 2003. I checked the file in the map that was given the rigths and it's all there. Is there somewhere else I can give these rights? Or must I reinstall Windows 2003?

            M 1 Reply Last reply
            0
            • L larbo204

              Ok. But what more can I do than to give NETWORK SERVICE all rights it should need? I tried to give it to ASPNET but that works for Windows XP, not Windows 2003. I checked the file in the map that was given the rigths and it's all there. Is there somewhere else I can give these rights? Or must I reinstall Windows 2003?

              M Offline
              M Offline
              Mike Ellison
              wrote on last edited by
              #6

              Are you absolutely certain that the aspnet_wp.exe process is running under the NETWORK SERVICE account? and if so, are you absolutely certain that the NETWORK SERVICE account has read/write privileges to both the file and the containing folder? You might double-check your machine.config file's processModel[^] configuration section (particularly username & password, and the impersonation settings) to be certain of the security account context under which aspnet_wp.exe is executing. If all that checks out, and you are absolutely certain the account priviliges are correct, then maybe the issue deals with ASP.NET code access security[^] settings for your application & server. FileIO is restricted in the Medium and Low security zones - perhaps that's what is going on? You may also find the Windows Server 2003 ASP.NET Security[^] documentation useful.

              A 1 Reply Last reply
              0
              • M Mike Ellison

                Are you absolutely certain that the aspnet_wp.exe process is running under the NETWORK SERVICE account? and if so, are you absolutely certain that the NETWORK SERVICE account has read/write privileges to both the file and the containing folder? You might double-check your machine.config file's processModel[^] configuration section (particularly username & password, and the impersonation settings) to be certain of the security account context under which aspnet_wp.exe is executing. If all that checks out, and you are absolutely certain the account priviliges are correct, then maybe the issue deals with ASP.NET code access security[^] settings for your application & server. FileIO is restricted in the Medium and Low security zones - perhaps that's what is going on? You may also find the Windows Server 2003 ASP.NET Security[^] documentation useful.

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                Where do I find if aspnet_wp.exe process is running under the NETWORK SERVICE account? I checked the properties->security of C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_wp.exe and there no 'NETWORK SERVICE' there, just 'SERVICE' with read/run and read privileges. The folder to the denied file has all privileges and files in the folder inherit those privileges. I tried IIS->Application pool->properties->Identity and it says: Predefined: Network service. I don't know what more to do there.

                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