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

G

gatekeeper

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..
 
P

Patrice

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
 
B

Brendan Green

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.
 

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

Top