PDA

View Full Version : File Update Access not Allowed



MartinJackson
01-01-2008, 06:50 PM
My ASP.NET program tries to add records to a text file in a folder I have created in the private part of my domain not in wwwroot. Read access is OK but writing results in a System.Security.Permissions.FileIOPermission error failure.

How do I give my write access?

siphilp
01-01-2008, 07:28 PM
why would you write it to a text file? Why not put it in a database?

MartinJackson
02-01-2008, 07:47 AM
I like text files. They are small, quick to copy, readable with notepad, primitive. Easy for recording outside the database. Easy for handling simple data.

siphilp
02-01-2008, 09:27 AM
probably the asp.net worker doesn't have write permissions on the file since it's outwith the wwwroot directory?

Is there a specific reason why the file is outside the normal web directory?

MartinJackson
02-01-2008, 01:11 PM
Not really.
I thought it would be more private there. There are already log files kept in that area.
I want the file to be accessed and updated only by my asp program and myself using FTP
If it was under the wwwroot I think it would be available across the Internet.

Mark Voss
02-01-2008, 02:20 PM
I know next to nothing about asp.net but you can do this with classic asp and the file system object - I use it to update the .htpasswd text file in the 'secure' folder above wwwroot (created when secure folders are installed from Helm).

You're right about text files in wwwroot Martin - they're accessible via any browser if you know the filename.

Ben Collier
02-01-2008, 02:51 PM
You're right about text files in wwwroot Martin - they're accessible via any browser if you know the filename.

You could rename the text file extension to .xyz and store it within the wwwroot, as it i not defined under 'mime types' it would not be served by the server (just did a test to confirm this) You could then download the file via FTP and open it with notepad.

Hope this makes sense!

Ben

Mark Voss
02-01-2008, 03:24 PM
You could rename the text file extension to .xyz and store it within the wwwroot
Yep, you could do this too - it should give a 404 file not found error even if you guess the filename & the dummy extension

FOD
04-01-2008, 08:14 AM
My ASP.NET program tries to add records to a text file in a folder I have created in the private part of my domain not in wwwroot. Read access is OK but writing results in a System.Security.Permissions.FileIOPermission error failure.

How do I give my write access?

Using classic asp I do exactly this daily - I think that the web client has RW access to folders outside wwwroot.

Assuming you have the path to the file correct and are not trying to write to a url.
(for me it's C:\Domains\french-owners-direct.com\Exch\Exch.xml)
I would ask Carl it is possible with asp.net

David.

MartinJackson
07-01-2008, 01:59 PM
Carl, I did have the path correct because I could read the file. I just didn't have Write access. I suspect you are right I just need to have the access switched on somehow.

Ben, Mark, Your trick worked great. Files in wwwroot folder and sub folders with obscure filename extensions are hidden from the www universe but I have Read-Write access in mt ASP.net program.

Thanks for all help. Martin