[Mono-list] Tilde

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Oct 18 00:52:25 EDT 2009


On Sun, Oct 18, 2009 at 12:14 AM, Chuck Esterbrook
<chuck.esterbrook at gmail.com> wrote:
> On Mono 2.4.2.3 on Mac OS X 10.6, File.exists('~/bin/foo') returns
> false even if ~/bin/foo exists, and Path.getFullPath('~/bin/foo`) does
> not expand the ~. Is this a bug? If not, am I missing a particular
> call? Hopefully, we're not all duplicating the work of implementing a
> MyUtils.getFullPath that checks for ~ (or lacking ~ support in our
> unix based apps).

AFAIK the ~ expansion is normally performed by the shell, it's not
part of the real file path.

You can get the home folder on non-Windows systems using
System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal). On Windows, this is the
user's My Documents folder.

See http://www.go-mono.com/docs/index.aspx?link=T%3aSystem.Environment.SpecialFolder

You probably also want to use System.IO.Path.Combine ("foo", "bar") or
System.IO.Path.DirectorySeparatorChar instead of hardcoding / in
paths.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Mono-list mailing list