Need to write files in asp.net 2.0

Discussion in 'ASP.NET 2.0' started by glowshotcom, Apr 21, 2007.

  1. Hello.

    I need to write files in my inside my asp.net 2.0 page. I tought I should have access to the folder where my application files are, but couldn't make it work.

    If i try to write using:

    FileStream writer = File.OpenWrite(Server.MapPath("file.txt"));

    then i get the following error message:

    Access to the path 'c:\windows\system32\inetsrv\file.txt' is denied.

    Any ideas?

    Thanks in advance.

    Post Edited By Moderator (mjp) : 4/23/2007 5:35:09 PM GMT
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    this error means that your application is trying to write to

    c:\windows\system32\inetsrv which is not allowed.



    thisline should be fine.

    FileStream writer = File.OpenWrite(Server.MapPath("file.txt"));

    I would dump out Server.MapPath("file.txt") and see what the value is. I don't think this line is causing te problem.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page