Help to solve error while reading a file?

E

Erland

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("mytxt.txt",FileMode.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\System32. Now my C Drive is FAT32. Please note that
name of my application is "MyWebProject".

Now i copy my project folder i.e. "MyWebProject" 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\system32\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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top