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

  • Thread starter Thread starter gatekeeper
  • Start date Start date
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..
 
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
 
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.
 
Back
Top