|
-
Jun 6th, 2003, 11:24 PM
#1
Thread Starter
PowerPoster
FileStreams in aspx page?
How can I write data using a filestream during a session? I've tried setting various IIS permissions, but I keep getting
System.UnauthorizedAccessException: Access to the path "C:\inetpub\wwwroot\whatever\data.txt" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) ...
Here's the relevant code:
Code:
private void BtnDotDotDot_Click(object sender, System.EventArgs e)
{
if (!this.IsPostBack)
return;
string sName = Request.QueryString.Get("name");
if (sName == null)
{
// ...
}
try
{
FileStream fs = new FileStream(Request.PhysicalApplicationPath + "\\data.txt",
FileMode.Append, FileAccess.Write, FileShare.Write);
StreamWriter sw = new StreamWriter(fs);
sw.AutoFlush = true;
sw.WriteLine("Name:\t" + sName + ":\t...");
sw.Close();
}
catch(Exception ex)
{
Response.Write(ex.ToString());
return;
}
}
Last edited by sunburnt; Jun 6th, 2003 at 11:28 PM.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jun 9th, 2003, 02:10 AM
#2
New Member
ASPNET
you just must give the rights to ASPNET user
right click button on the file or the folder you want
then security
and add ASPNET
give full rights
......and you are done
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|