首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何调用Ubuntu系统打开或保存像Windows这样的文件对话框

如何调用Ubuntu系统打开或保存像Windows这样的文件对话框
EN

Ask Ubuntu用户
提问于 2019-04-01 10:04:47
回答 1查看 618关注 0票数 0

我正在使用C#,我想做一些类似于当我单击save时弹出的Windows,但是我不知道如何做到这一点。

谢谢你的帮助。对不起,我的英语很差。

EN

回答 1

Ask Ubuntu用户

发布于 2019-04-01 10:15:01

你可以用Gtk.FileChooserDialog来做

代码语言:javascript
复制
Gtk.FileChooserDialog Class

Gtk.FileChooserDialog是一个对话框,适合与“文件/打开”或“文件/另存为”命令一起使用。这个小部件通过在一个Gtk.FileChooserWidget中放置一个Gtk.Dialog来工作。它公开了Gtk.FileChooser接口,因此您可以使用文件选择器对话框中的所有Gtk.FileChooser函数以及用于Gtk.Dialog的函数。

代码语言:javascript
复制
public class MainWindow: Gtk.Window {

    protected virtual void OnBtnLoadFileClicked(object sender, System.EventArgs e)
    {
        Gtk.FileChooserDialog fc=
        new Gtk.FileChooserDialog("Choose the file to open",
                                    this,
                                    FileChooserAction.Open,
                                    "Cancel",ResponseType.Cancel,
                                    "Open",ResponseType.Accept);

        if (fc.Run() == (int)ResponseType.Accept) 
        {
            System.IO.FileStream file=System.IO.File.OpenRead(fc.Filename);
            file.Close();
        }
        //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
        fc.Destroy();
    }

在这里阅读更多信息:http://docs.go-mono.com/index.aspx?link=T%3AGtk.FileChooserDialog

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1130305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档