首页 > 其他 > 详细

Using Open File Dialog in WPF

时间:2014-10-06 15:54:50      阅读:211      评论:0      收藏:0      [点我收藏+]
 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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!