How do I write a .csv to disk?

Discussion in 'ASP.NET / ASP.NET Core' started by screamingsa, Nov 1, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I need some assistance from all of you web gurus... I'm trying to write a file to disk and keep getting the error:

    Exception Details: System.UnauthorizedAccessException: Access to the path "c:\windows\system32\inetsrv\myfile.csv" is denied.

    I don't want to write to c: -- I want to write to a folder (e.g. downloads on my site) I'm using filename = "~/" & myfilename right now and I guess this isn't the correct syntax... Is anyone out there that could provide some help?

    Thanks!

    Lance
     
  2. if you want to write the folder to the same path as the website directory call your file this:

    Server.Path("myfile.csv")

    the reason you are getting access denied is because when you put
    "~/" & myfilename it will save your file to the system folder. the aspnet user probably doesnt have write access to the system folder.

    hth
    matt
     
  3. I used server.MapPath("whatever.txt")
     
  4. Thanks Guys!
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page