[Mono-osx] How to write files to (and read from) special folders

Richard de Zwart mountain at xs4all.nl
Tue Dec 28 14:51:14 EST 2010

I found a discussion on macworld.com 
(http://hintsforums.macworld.com/showthread.php?t=100909) that says that 
you never know the context before hand. It depends on the place your app 
was started. You should use "~/Library/Application 
Support/yourapplication". Does the MonoMac community agree?


P.S. For reading resources I can use NSBundle.MainBundle.ResourcePath, 
and I can write there too. So what about the Application Support dir?

On 12/28/10 8:31 PM, Richard de Zwart wrote:
> Dear all,
> When I write a file without a path it ends up in the root of my machine.
> Code like this :
> File.WriteAllText("foo.txt", "This is some text");
> creates a file "/foo.txt".
> I would like to write into the app folder of my application, maybe by
> using some Environment.SpecialFolder enum like I use in a MonoTouch
> application. But the available enumerations give me machine-wide paths
> like "/Users/Shared".
> When I want the open a file that I marked as "Content" in my solution in
> MonoDevelop I need to specify the entire path to my bin/Debug directory.
> Which of course will not work when I deploy my app.
> Apparently the context of my running application is the root. Can I
> change that?
> Thanks,
> Richard
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx

More information about the Mono-osx mailing list