博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# Windows-API-Code-Pack文件选择对话框实例
阅读量:4287 次
发布时间:2019-05-27

本文共 2754 字,大约阅读时间需要 9 分钟。

一、新建Wpf项目,需要添加引用

Install-Package WindowsAPICodePack-CoreInstall-Package WindowsAPICodePack-Shell

二、选择文件对话框实例CommonOpenFileDialog

选择媒体文件

//指定视频文件夹选择视频文件//系统文件夹可能会获取失败//ShellContainer selFolder = KnownFolders.SampleMusic as ShellContainer;CommonOpenFileDialog open = new CommonOpenFileDialog();//open.InitialDirectoryShellContainer = selFolder;open.EnsureReadOnly = true;open.Filters.Add(new CommonFileDialogFilter("Mp4文件", "*.mp4"));open.Filters.Add(new CommonFileDialogFilter("Wmv文件","*.wmv"));open.Filters.Add(new CommonFileDialogFilter("Avi文件", "*.avi"));open.Filters.Add(new CommonFileDialogFilter("Mp3文件", "*.mp3"));if (open.ShowDialog() == CommonFileDialogResult.Ok){    //指定媒体文件地址    mediaElement.Source = new Uri(open.FileName,UriKind.Relative);    playBtn.

三、Microsoft.WindowsAPICodePack.Dialogs Namespace部分类

Class Description
CommonFileDialog

Defines the abstract base class for the common file dialogs.

CommonFileDialogFilter

Stores the file extensions used when filtering files in File Open and File Save dialogs.

CommonFileDialogFilterCollection

Provides a strongly typed collection for file dialog filters.

CommonFileDialogFolderChangeEventArgs

Creates the event data associated with FolderChanging event.

CommonFileDialogStandardFilters

Defines the class of commonly used file filters.

CommonOpenFileDialog

Creates a Vista or Windows 7 Common File Dialog, allowing the user to select one or more files.

CommonSaveFileDialog

Creates a Vista or Windows 7 Common File Dialog, allowing the user to select the filename and location for a saved file.

DialogControl

Abstract base class for all dialog controls

DialogControlCollection<(Of<(<'T>)>)>

Strongly typed collection for dialog controls.

TaskDialog

Encapsulates a new-to-Vista Win32 TaskDialog window - a powerful successor to the MessageBox 

available in previous versions of Windows.

TaskDialogBar

Defines a common class for all task dialog bar controls, such as the progress and marquee bars.

TaskDialogButton

Implements a button that can be hosted in a task dialog.

TaskDialogButtonBase

Defines the abstract base class for task dialog buttons. 

Classes that inherit from this class will inherit the Text property defined in this class.

TaskDialogClosingEventArgs

Data associated with Closing event.

TaskDialogCommandLink

Represents a command-link.

TaskDialogControl

Declares the abstract base class for all custom task dialog controls.

TaskDialogHyperlinkClickedEventArgs

Defines event data associated with a HyperlinkClick event.

TaskDialogProgressBar

Provides a visual representation of the progress of a long running operation.

TaskDialogRadioButton

Defines a radio button that can be hosted in by a TaskDialog object.

TaskDialogTickEventArgs

The event data for a TaskDialogTick event.  

你可能感兴趣的文章
html入门之meta
查看>>
Spring源码和jar包下载步骤
查看>>
一位资深程序员大牛给予Java初学者的学习路线建议
查看>>
spring中bean的自动装配和作用域
查看>>
使用http请求,中文乱码问题--解决方法
查看>>
mybatis入门之接口式编程
查看>>
html页面中iframe嵌套页面的父页面和子页面js方法互相调用
查看>>
求字符串中变换位置问题
查看>>
求这个字符串中的最大的数字字符串
查看>>
Spring报错:java.lang.ClassCastException: com.sun.proxy.$Proxy2 cannot be cast to *
查看>>
Java一键启动Linux上的tomcat服务器
查看>>
java实现导出excel表到磁盘上(三)---完整封装,可直接使用
查看>>
json.loads
查看>>
快速截屏小工具
查看>>
如何用github发布Axure原型
查看>>
selenium RC+JAVA 运行所遇到的问题
查看>>
python运行时提示WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
查看>>
selenuim +python环境配置遇到的诸多问题
查看>>
selenium + python自动化测试环境搭建
查看>>
轻松自动化---selenium-webdriver(python) (一)
查看>>