473,387 Members | 1,549 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.

streamwriter working in windows but not web...?why?

Why could it be that i am able to use StreamWriter from a
windows application but not from a web application?

I am getting an unauthorizedaccessexception and the
exception message is "Access to the path... is denied".

the code i'm using is very straightforward:

using System.IO;
....
StreamWriter sw = new StreamWriter(@"C:\Testing123.txt");
sw.Write("web");
sw.Close();

i am baffled.

Is this a security issue?

thank you in advance..

Jul 21 '05 #1
2 1170
Very likely...

Keep in mind that a web application runs with its own account... As a side
note, even in a windows application, writing to the root with XP is likely
not possible for non administrative users...

Usually the app runs under the ASPNET account. Check to see if this is
allowed (and once this quick test is done user perhaps something else than
the root).

Patrice
--

"gatekeeper" <an*******@discussions.microsoft.com> a écrit dans le message
de news:15****************************@phx.gbl...
Why could it be that i am able to use StreamWriter from a
windows application but not from a web application?

I am getting an unauthorizedaccessexception and the
exception message is "Access to the path... is denied".

the code i'm using is very straightforward:

using System.IO;
...
StreamWriter sw = new StreamWriter(@"C:\Testing123.txt");
sw.Write("web");
sw.Close();

i am baffled.

Is this a security issue?

thank you in advance..

Jul 21 '05 #2
The ASPNET account has very limited access to the filesystem. I would think
twice about giving this account write access to anywhere other than the
location of the website.

"Patrice" <no****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Very likely...

Keep in mind that a web application runs with its own account... As a side
note, even in a windows application, writing to the root with XP is likely
not possible for non administrative users...

Usually the app runs under the ASPNET account. Check to see if this is
allowed (and once this quick test is done user perhaps something else than
the root).

Patrice
--

"gatekeeper" <an*******@discussions.microsoft.com> a écrit dans le message
de news:15****************************@phx.gbl...
Why could it be that i am able to use StreamWriter from a
windows application but not from a web application?

I am getting an unauthorizedaccessexception and the
exception message is "Access to the path... is denied".

the code i'm using is very straightforward:

using System.IO;
...
StreamWriter sw = new StreamWriter(@"C:\Testing123.txt");
sw.Write("web");
sw.Close();

i am baffled.

Is this a security issue?

thank you in advance..


Jul 21 '05 #3

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

Similar topics

0
by: notalent | last post by:
I'm having a problem with a very basic program. I'm creating a app in Visual Studio (2003) C# to zip up a collection of specified files & directories and save them to a certain location. I have...
3
by: Don | last post by:
I have a strange bug popping up every once in a while. I've got a section of code that executes these statements when working with a streamwriter: --- Start --- .... ' Close the...
2
by: David Buchan | last post by:
I have written a program to write some text to a file. Currently, if the file already exists, the program simply overwrites it. What I'd like to do, is have the program ask me if I wish to...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
3
by: gatekeeper | last post by:
Why could it be that i am able to use StreamWriter from a windows application but not from a web application? I am getting an unauthorizedaccessexception and the exception message is "Access to...
2
by: sameer | last post by:
Hi, My very simple application VB.NET Visual Studio 2003 console application uses a log file to write some text to it. I am using StreamWriter object to create and open and then append text to...
2
by: MATT | last post by:
I am trying to create a windows service. The part I am having trouble with is writing text to a log file. I am using a very basic StreamWriter function to try to test this. I have created a...
1
by: Merk | last post by:
In a 2.0 Windows Forms app... in a static class I have a method named WriteToLocalLog() that writes to a text file on the local machine. I declare a StreamWriter at the class level (not inside...
3
by: stumorgan | last post by:
I'm doing some USB communications in C# and am running into a minor annoyance. I'm using the Windows API CreateFile function to get a SafeFileHandle, which I then stuff into a FileStream and from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.