[Mono-list] Opening a file from .aspx
tymoteuszmajewski at yahoo.com.au
Sun Jul 25 21:48:14 EDT 2010
From: Tymoteusz Majewski <tymoteuszmajewski at yahoo.com.au>
To: Mono <mono-list at lists.ximian.com>
Sent: Tue, 20 July, 2010 7:36:30 PM
Subject: [Mono-list] Opening a file from .aspx
>This is on ubuntu, Mono JIT compiler version 18.104.22.168
>I have mono setup which I can run c# scripts properly, but I cannot open files.
> string file = "Config/1.txt";
> file = Server.MapPath (file);
> File.Open (file, FileMode.Open);
>Access to the path "/MyPages/website/Config/1.txt" is denied.
>The file is accessible through apache, meaning I can go to
>"http://192.168.1.125/Config/1.txt"; and I can read the file.
>If I run the same code from a mono app (not from .aspx page) it works fine.
>I read quite a lot about trustLevels, securityPolicy in web.config files, but
>things just don't seem to have any effect.
>When I tried to establish the current policy level from the page itself it
>reports as Unrestricted which is an issue on its own, but that's an issue for
>I tried to find something about trust levels in mono asp but I cannot find
>The bottom line is I would like to:
>a) open and read a file from within the website's directory.
>b) open and read a file from a specified directory not in the application's
>(website's root dir).
>Thank you in advance.
I wasn't able to make File.Open work (even though File.Exists seems to behave
properly) but StreamReader reads the files.
StreamReader sr=new StreamReader(file);
while (sr.Peek() >= 0)
More information about the Mono-list