473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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("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

Apr 12 '06 #1
1 1437
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:
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

Apr 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: wonder | last post by:
Hi, The CRM application said that need to add an option "REGISTER_GLOBALS=On" to the php.ini file, so I did what it told. But I still can't get rid off the following error: The PHP variable...
1
by: Ram | last post by:
Dear All I am very new to python . i would appreciate any help from you all on this problem which i am facing. I am trying to connect to postgres from python.for this i am using something like...
1
by: Hafeez | last post by:
I am having real trouble compiling this code http://www.cs.wisc.edu/~vganti/birchcode/codeHier/AttrProj.tgz The attachment shows errors when compiled using the current version of g++ in a...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
2
by: Erland | last post by:
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";...
1
by: Nestor | last post by:
Hello all, I'm begining in the web services world and I've reading about how to invoke them using javascript from Mozilla browser (version 2.0 in my case). I found a very interesting example...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: Sean128 | last post by:
Hi, I hope someone can help me - this seems like it should be a really simple problem but I've been having trouble trying to solve it all week. I have hosted my website on a Linux server in 1...
1
by: Sean128 | last post by:
Hi, I hope someone can help me - this seems like it should be a really simple problem but I've been having trouble trying to solve it all week. I have hosted my website on a Linux server in 1...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.