如何:向文件对话框添加自定义区域

更新:2007 年 11 月

对于 Windows Vista 上的默认打开和保存对话框,其左侧有一个标题为“收藏夹链接”的区域。此区域称作自定义区域。使用 OpenFileDialogSaveFileDialog 类可向 CustomPlaces 集合添加文件夹。

说明:

为了使自定义区域能显示在 OpenFileDialogSaveFileDialog 中,AutoUpgradeEnabled 属性必须设置为 true(默认值)。

向文件对话框添加自定义区域

  • 将路径、“已知文件夹”GUID 或 FileDialogCustomPlace 对象添加到对话框的 CustomPlaces 集合中。

    下面的代码示例演示了如何添加路径:

    OpenFileDialog1.CustomPlaces.Add("C:\MyCustomPlace")
    
    openFileDialog1.CustomPlaces.Add("C:\\MyCustomPlace");
    

请参见

概念

文件对话框自定义区域的已知文件夹 GUID

参考

FileDialog

FileDialogCustomPlacesCollection.Add

其他资源

FileDialog 类