Using Open File Dialog in WPF

 1             // Create OpenFileDialog
 2             Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
 3
 4             // Set filter for file extension and default file extension
 5             dlg.DefaultExt = ".txt";
 6             dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
 7
 8             // Display OpenFileDialog by calling ShowDialog method
 9             Nullable<bool> result = dlg.ShowDialog();
10
11             // Get the selected file name and display in a TextBox
12             if (result == true)
13             {
14                 // Open document
15                 string filename = dlg.FileName;
16                 this.txtPlace.Text = filename;
17             }
时间: 2024-10-11 11:18:33

Using Open File Dialog in WPF的相关文章

Inaccurate values for &ldquo;Currently allocated space&rdquo; and &ldquo;Available free space&rdquo; in the Shrink File dialog for TEMPDB only

转载自:http://blogs.msdn.com/b/ialonso/archive/2012/10/08/inaccurate-values-for-currently-allocated-space-and-available-free-space-in-the-shrink-file-dialog-for-tempdb-only.aspx   Inaccurate values for "Currently allocated space" and "Availabl

Using Save As Dialog in WPF

1 Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); 2 dlg.FileName = "User.txt"; // Default file name 3 dlg.DefaultExt = ".txt"; // Default file extension 4 dlg.Filter = "Text documents (.txt)|*.txt";

2000条你应知的WPF小姿势 基础篇&lt;78-81 Dialog/Location/WPF设备无关性&gt;

在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师.最为出色的是他维护了两个博客:2,000ThingsYou Should Know About C# 和 2,000 Things You Should Know About WPF .他以类似微博式的150字简短语言来每天更新一条WPF和C#重要又容易被遗忘的知识.很希望能够分享给大家. 本系列我不仅会翻译他的每一个tip,也会加入自己开发之中的看法和见解.本系列我希望自己也能和他一样坚持下来,每天的进步才能

node-webkit File Dialog

1. 多次选择相同的路径时,chooser.onchange 事件不触发 参考链接 Choosing the same directory multiple times Once the chooser has been used to select a directory (or the same file path + file name), the change event will not fire again since the value of the input is alread

WPF借助SaveFileDialog实现文件存储

以下是我的代码,对初涉WPF者有点用.wholestring是要写入文件的字符串. Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); //可能要获取的路径名 string localFilePath = "", fileNameExt = "", newFileName = "", FilePath = ""

Walkthrough: My first WPF desktop application

Walkthrough: My first WPF desktop application This article shows you how to develop a Windows Presentation Foundation (WPF) desktop application that includes the elements that are common to most WPF applications: Extensible Application Markup Languag

How to Change Default Location for Outlook Data File (PST &amp; OST)

Is there a way to change the default location of new .pst file when create a new e-mail account in Outlook? Different versions of Outlook use different default locations to store pst files. In this tutorial we'll show you how to change default locati

ux.plup.File plupload 集成 ux.plup.FileLis 批量上传预览

1 //plupload 集成 2 Ext.define('ux.plup.File', { 3 extend: 'Ext.form.field.Text', 4 xtype: 'plupFile', 5 alias: ['widget.plupFile'], 6 requires: ['Ext.form.trigger.Component', 'Ext.button.Button', 'Ext.window.Toast'], 7 //plup对象 8 uploader: null, 9 //上

C# 实验感悟WPF

实验程序:todolist 本次博客主要记录实验程序开发过程. 1 public void Save() 2 { 3 System.Text.StringBuilder report = new System.Text.StringBuilder(); 4 foreach (Task toDoItem in taskList) 5 { 6 report.Append(toDoItem.TaskTitle.ToString() + "\t" + toDoItem.TaskDescript