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. Writing text file in Visual studio .net 2003

Writing text file in Visual studio .net 2003

Scheduled Pinned Locked Moved Web Development
helpcsharpasp-netvisual-studiosysadmin
14 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.
  • J Offline
    J Offline
    Junior Boy
    wrote on last edited by
    #1

    I have been trying to write a text file on VB .net 2003 and finally I tried to copy the same code and then paste on VB .net 2005 it worked. I don't know how to fix this problem on VB .net 2003. Anybody who know how to fix this problem? Here is the errow detial it shown me on VB .net 2003 ================================================================================================= Access to the path "c:\mytext.txt" is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path "c:\mytext.txt" is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. ================================================================================================= Please help me if you know how. Thank you very much.

    junior boy

    E 1 Reply Last reply
    0
    • J Junior Boy

      I have been trying to write a text file on VB .net 2003 and finally I tried to copy the same code and then paste on VB .net 2005 it worked. I don't know how to fix this problem on VB .net 2003. Anybody who know how to fix this problem? Here is the errow detial it shown me on VB .net 2003 ================================================================================================= Access to the path "c:\mytext.txt" is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path "c:\mytext.txt" is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. ================================================================================================= Please help me if you know how. Thank you very much.

      junior boy

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      The system user account ASP.NET doesn't have rights to the file on the web machine. Give it rights and it will work fine.

      The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

      J 1 Reply Last reply
      0
      • E Expert Coming

        The system user account ASP.NET doesn't have rights to the file on the web machine. Give it rights and it will work fine.

        The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

        J Offline
        J Offline
        Junior Boy
        wrote on last edited by
        #3

        Please, Can you tell me more how to do it? I still have no idea to do it,please. Thank you advance.

        junior boy

        E 1 Reply Last reply
        0
        • J Junior Boy

          Please, Can you tell me more how to do it? I still have no idea to do it,please. Thank you advance.

          junior boy

          E Offline
          E Offline
          Expert Coming
          wrote on last edited by
          #4

          Ok go to the file you are trying to give access to write to. Right click on it goto the security tab. Click the add button. Add the user called IUSR_[machinename]. Give it read/write rights. To make this clear. If you servers name is myserver IUSR_[machinename] = IUSR_myserver Tell me if all is good.

          The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

          J 1 Reply Last reply
          0
          • E Expert Coming

            Ok go to the file you are trying to give access to write to. Right click on it goto the security tab. Click the add button. Add the user called IUSR_[machinename]. Give it read/write rights. To make this clear. If you servers name is myserver IUSR_[machinename] = IUSR_myserver Tell me if all is good.

            The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

            J Offline
            J Offline
            Junior Boy
            wrote on last edited by
            #5

            Well, I kept looking for the file and finally i tried to create the text file and tried to fallow your suggestion but I didn't see any ADD button when I right-click but I saw only the General tab and Summary tab has no security tab.After that i can't follow with your suggestion anymore :( here is more error deatial: ========================================================================================= Source Error: Line 21: { Line 22: // Put user code to initialize the page here Line 23: FileStream outStream=File.Create("c:\\mytext.txt"); Line 24: StreamWriter st=new StreamWriter(outStream); Line 25: st.WriteLine(DateTime.Now.ToString()); Source File: c:\inetpub\wwwroot\convert2chart\test.aspx.cs Line: 23 ========================================================================================= I really appreciated for your helping and hope you will understand and try to help me again,please. Thank you very much.

            junior boy

            E D 2 Replies Last reply
            0
            • J Junior Boy

              Well, I kept looking for the file and finally i tried to create the text file and tried to fallow your suggestion but I didn't see any ADD button when I right-click but I saw only the General tab and Summary tab has no security tab.After that i can't follow with your suggestion anymore :( here is more error deatial: ========================================================================================= Source Error: Line 21: { Line 22: // Put user code to initialize the page here Line 23: FileStream outStream=File.Create("c:\\mytext.txt"); Line 24: StreamWriter st=new StreamWriter(outStream); Line 25: st.WriteLine(DateTime.Now.ToString()); Source File: c:\inetpub\wwwroot\convert2chart\test.aspx.cs Line: 23 ========================================================================================= I really appreciated for your helping and hope you will understand and try to help me again,please. Thank you very much.

              junior boy

              E Offline
              E Offline
              Expert Coming
              wrote on last edited by
              #6

              Change line 23 to: FileStream outStream = new FileStream("c:\\mytext.txt", FileMode.Create, FileAccess.Read);

              The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

              J 1 Reply Last reply
              0
              • E Expert Coming

                Change line 23 to: FileStream outStream = new FileStream("c:\\mytext.txt", FileMode.Create, FileAccess.Read);

                The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

                J Offline
                J Offline
                Junior Boy
                wrote on last edited by
                #7

                I coppied your code and paste it and then run it and this is the result : =================================================================================================== Combining FileMode: Create with FileAccess: Read is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Combining FileMode: Create with FileAccess: Read is invalid. Source Error: Line 22: // Put user code to initialize the page here Line 23: //FileStream outStream=File.Create("c:\\mytext.txt"); Line 24: FileStream outStream = new FileStream("c:\\mytext.txt", FileMode.Create, FileAccess.Read); Line 25: StreamWriter st=new StreamWriter(outStream); Line 26: st.WriteLine(DateTime.Now.ToString()); Source File: c:\inetpub\wwwroot\convert2chart\test.aspx.cs Line: 24 =================================================================================================== And I tried to change the FileAccess to ReadWrite and it has debugged and the error detail the same the first post message I shown you. =================================================================================================== Access to the path "c:\mytext.txt" is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access to the path "c:\mytext.txt" is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. Source Error: Line 22: // Put user code to initialize the page here Line 23: //FileStream outStream=File.Create("c:\\mytext.txt")

                1 Reply Last reply
                0
                • J Junior Boy

                  Well, I kept looking for the file and finally i tried to create the text file and tried to fallow your suggestion but I didn't see any ADD button when I right-click but I saw only the General tab and Summary tab has no security tab.After that i can't follow with your suggestion anymore :( here is more error deatial: ========================================================================================= Source Error: Line 21: { Line 22: // Put user code to initialize the page here Line 23: FileStream outStream=File.Create("c:\\mytext.txt"); Line 24: StreamWriter st=new StreamWriter(outStream); Line 25: st.WriteLine(DateTime.Now.ToString()); Source File: c:\inetpub\wwwroot\convert2chart\test.aspx.cs Line: 23 ========================================================================================= I really appreciated for your helping and hope you will understand and try to help me again,please. Thank you very much.

                  junior boy

                  D Offline
                  D Offline
                  DavidNohejl
                  wrote on last edited by
                  #8

                  Junior Boy wrote:

                  I saw only the General tab and Summary tab has no security tab

                  Are you logged in as administrator? I am not sure but that might be the reason why there is no security tab.


                  "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

                  J 1 Reply Last reply
                  0
                  • D DavidNohejl

                    Junior Boy wrote:

                    I saw only the General tab and Summary tab has no security tab

                    Are you logged in as administrator? I am not sure but that might be the reason why there is no security tab.


                    "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

                    J Offline
                    J Offline
                    Junior Boy
                    wrote on last edited by
                    #9

                    yes,sure I am. But I didn't see any Security tab. Any suggestion from you or anything else I should know about,please? thank you,

                    junior boy

                    D E 2 Replies Last reply
                    0
                    • J Junior Boy

                      yes,sure I am. But I didn't see any Security tab. Any suggestion from you or anything else I should know about,please? thank you,

                      junior boy

                      D Offline
                      D Offline
                      DavidNohejl
                      wrote on last edited by
                      #10

                      I've googled: http://www.spaanjaars.com/QuickDocId.aspx?quickdoc=286[^] That should help.


                      "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

                      1 Reply Last reply
                      0
                      • J Junior Boy

                        yes,sure I am. But I didn't see any Security tab. Any suggestion from you or anything else I should know about,please? thank you,

                        junior boy

                        E Offline
                        E Offline
                        Expert Coming
                        wrote on last edited by
                        #11

                        Do you have the security tab after following those directions? If so, add the user I mentioned earlier and see if it works.

                        The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

                        J 1 Reply Last reply
                        0
                        • E Expert Coming

                          Do you have the security tab after following those directions? If so, add the user I mentioned earlier and see if it works.

                          The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

                          J Offline
                          J Offline
                          Junior Boy
                          wrote on last edited by
                          #12

                          Hi guys Finally I can wrote some text to the text file. Because I have to go back and check in the checkbox below to full control and it worked But you guys please,i have another problem it is I have to create the text file first, I mean I need to have a textfile and I have to go right-click and do the same again and again. My purpose is doesn't matter I have the textfile or not just create and write some textual into it. And the error is the same such as the first time. Can you tell me how to do? Thank you very much.

                          junior boy

                          P 1 Reply Last reply
                          0
                          • J Junior Boy

                            Hi guys Finally I can wrote some text to the text file. Because I have to go back and check in the checkbox below to full control and it worked But you guys please,i have another problem it is I have to create the text file first, I mean I need to have a textfile and I have to go right-click and do the same again and again. My purpose is doesn't matter I have the textfile or not just create and write some textual into it. And the error is the same such as the first time. Can you tell me how to do? Thank you very much.

                            junior boy

                            P Offline
                            P Offline
                            Paddy Boyd
                            wrote on last edited by
                            #13

                            You should be able to apply the security settings to the directory the file is in.

                            J 1 Reply Last reply
                            0
                            • P Paddy Boyd

                              You should be able to apply the security settings to the directory the file is in.

                              J Offline
                              J Offline
                              Junior Boy
                              wrote on last edited by
                              #14

                              Thank you for all helps from all you guys. Now I decided to use VB .net 2005 to avoid this problem and some people told me that it is bugging on VB .net 2003 Probably its right because I have no problem when I tried to use VB .net 2005 Really glad for helping. Good luck,have nice day all you guys,

                              junior boy

                              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