Results 1 to 2 of 2

Thread: FileStreams in aspx page?

  1. #1

    Thread Starter
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    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.

  2. #2
    New Member
    Join Date
    Jun 2003
    Posts
    9

    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
    angiras

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width