Help to solve error while reading a file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erland

    Help to solve error while reading a file?

    Hi all,

    I have made an ASP.NET 1.1 application on windows 2000 advanced server.
    In the application, i have saved the file using the following code

    string str;
    str="this is my data";
    FileStream fs=new FileStream("myt xt.txt",FileMod e.open);
    StreamWriter sr=new StreamWriter (fs);
    sr.Write(str);


    Now i can write the file and even read it on my system. It saves the
    file in my C:\WINNT\System 32. Now my C Drive is FAT32. Please note that
    name of my application is "MyWebProje ct".

    Now i copy my project folder i.e. "MyWebProje ct" from wwwrooot and take
    to other system and saves the file in other system that is running Win
    XP which has IIS installed. I have made a virtual directory that maps
    to the file i just copied from Win 2000. Please also note that C Drive
    of Win XP is NTFS.
    Now when i try to run my application on Win XP, it throws an error
    which is as following
    --------------------------------------------------------------------------------------------------------------------
    Access to the path "C:\WINDOWS\sys tem32\mytxt.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.
    --------------------------------------------------------------------------------------------------------------------

    Now please let me know what i am doing wrong here, if i have to set
    some seucrity permissions within my XP machine then please let me know
    how should i go about it?
    OR if there is some other error then please let me know what it is....
    I appreciate your time and thanks in advance.

    -Erland

  • Dale

    #2
    RE: Help to solve error while reading a file?

    Well, one thing you don't want to do is to grant your ASPNET account access
    to your system32 folder. Move the file to the web application folder and you
    don't have to do a thing to read it. If you have to write the file, include
    the full path or use Server.MapPath to get the path to the file so that it
    won't default to System32.

    If you definitely want it out of the application folder, create a different
    folder that is not in your Windows directory for your virtual folder and make
    sure that ASPNET has write permissions to it.

    HTH
    --
    Dale Preston
    MCAD C#
    MCSE, MCDBA


    "Erland" wrote:
    [color=blue]
    > Hi all,
    >
    > I have made an ASP.NET 1.1 application on windows 2000 advanced server.
    > In the application, i have saved the file using the following code
    >
    > string str;
    > str="this is my data";
    > FileStream fs=new FileStream("myt xt.txt",FileMod e.open);
    > StreamWriter sr=new StreamWriter (fs);
    > sr.Write(str);
    >
    >
    > Now i can write the file and even read it on my system. It saves the
    > file in my C:\WINNT\System 32. Now my C Drive is FAT32. Please note that
    > name of my application is "MyWebProje ct".
    >
    > Now i copy my project folder i.e. "MyWebProje ct" from wwwrooot and take
    > to other system and saves the file in other system that is running Win
    > XP which has IIS installed. I have made a virtual directory that maps
    > to the file i just copied from Win 2000. Please also note that C Drive
    > of Win XP is NTFS.
    > Now when i try to run my application on Win XP, it throws an error
    > which is as following
    > --------------------------------------------------------------------------------------------------------------------
    > Access to the path "C:\WINDOWS\sys tem32\mytxt.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.
    > --------------------------------------------------------------------------------------------------------------------
    >
    > Now please let me know what i am doing wrong here, if i have to set
    > some seucrity permissions within my XP machine then please let me know
    > how should i go about it?
    > OR if there is some other error then please let me know what it is....
    > I appreciate your time and thanks in advance.
    >
    > -Erland
    >
    >[/color]

    Comment

    Working...