码迷,mamicode.com
首页 > 其他好文 > 详细

Using Open File Dialog in WPF

时间:2014-10-06 16:19:10      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   for   sp   div   c   

 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             }

 

Using Open File Dialog in WPF

标签:style   blog   color   io   os   for   sp   div   c   

原文地址:http://www.cnblogs.com/cicaday/p/4008235.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!