如何将 gtk 文件选择器按钮默认设置为用户的主文件夹

发布于 2024-08-29 10:32:36 字数 193 浏览 13 评论 0原文

我的应用程序上有一个 gtk 文件选择器按钮,我正在使用 Mono Develop 用 c# 编写。我想将文件选择器的默认位置设置为用户的主目录,无论哪个用户正在运行它。

我尝试过 ~/ 快捷方式 - fchFolder1.SetCurrentFolder("~/"); - 但这没有用。我只是想知道 gtk 文件选择器是否使用一个值来引用用户主目录?谢谢

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.SetCurrentFolder("~/"); - 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

手长情犹 2024-09-05 10:32:36

在 C 中,可以使用 g_get_home_dir() 查找用户的主目录,并将文件选择器的当前位置设置为该目录,但据我所知,该函数并未包含在 GTK# 中。有人在 GTK# 邮件中提出了同样的问题列出,答案是使用

System.Environment.GetFolderPath (SpecialFolder.Personal)

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)
云归处 2024-09-05 10:32:36

在 Unix 中,您可以获取 HOME 环境变量或使用 System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal

在 Windows 中,展开 %HOMEDRIVE%%HOMEPATH% 以获取“主”目录,或使用相同的 GetFolderPath 调用来获取“我的文档”目录。

关于 HOME 和 HOMEDRIVE+HOMEPATH 方法的讨论:获取C# 中的主目录?

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#?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文