开发者

How to set gtk file chooser button default to user's home folder

开发者 https://www.devze.com 2022-12-26 23:32 出处:网络
I\'ve got a gtk file chooser button on my application I am writing in c# using Mono Develop. I would like to set the file chooser\'s default location to the users\' home directory regardless of what u

I've got a gtk file chooser button on my application I am writing in c# using Mono Develop. I would like to set the file chooser's default location to the users' home directory regardless of what user is running it.

I've tried the ~/ short cut - fchFolder1.S开发者_开发技巧etCurrentFolder("~/"); - but this did not work. I was just wondering if there was a value that the gtk file chooser used to refer to the users home directory? Thanks


In C, one would use g_get_home_dir() to find the user's home directory, and set the file chooser's current location to that, but as far as I can tell, that function isn't wrapped in GTK#. Someone asked the same question on the GTK# mailing list and the answer was to use

System.Environment.GetFolderPath (SpecialFolder.Personal)


In Unix, you can either get the HOME environment variable or use System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal).

In Windows, expand %HOMEDRIVE%%HOMEPATH% to get the "home" directory, or use the same GetFolderPath call to get the "My Documents" directory.

Discussion about the HOME and HOMEDRIVE+HOMEPATH approach: Getting the path of the home directory in C#?

0

精彩评论

暂无评论...
验证码 换一张
取 消