C # Select a file, select a folder, open a file (or a folder)

Source: Internet
Author: User

Http://www.cnblogs.com/zhlziliaoku/p/5241097.html

1. Select File with OpenDialog

Newtrue;  " Please select folder "" All Files (*. *) |*.*";  if (dialog. ShowDialog () = =String file = dialog. FileName;}           
The Filter property is assigned a string to filter the file type, and the string is described as follows: ' | ' Split two, one is a comment, one is a true filter, and the comment is displayed. If you want to display files of more than one type at a time, separate them with semicolons. such as: open1.filter=" picture file (*.jpg,*.gif,*.bmp) |*.jpg;*.gif;*.bmp"; Thefilter file type is "|" *.jpg;*.gif;*.bmp three types of files on the right, and the file type strings shown to the user in Opendialog/savedialog are: "|" Image file (*.jpg,*.gif,*. bmp) to the left of the number. Again such as: open1.filter=" image file (*.jpg;*.jpg;*.jpeg;*.gif;*.png) |*.jpg;*.jpeg;*.gif;*.png";     

2. Use System.Windows.Forms.FolderBrowserDialog to select folders

System.Windows.Forms.FolderBrowserDialog dialog =NewSystem.Windows.Forms.FolderBrowserDialog ();d ialog. Description ="Please select the folder where TXT is located";if (dialog. ShowDialog () = =System.Windows.Forms.DialogResult.OK) {if (String. IsNullOrEmpty (dialog. SelectedPath)) {System.Windows.MessageBox.Show (This , " folder path cannot be empty ", " hint "); return;} This . Loadingtext = " in Process ... "; This . Loadingdisplay = true; action<string> a = daorudata; a.begininvoke (dialog. Selectedpath,asynccallback, a);}               

3. Open a file or folder directly under a path

System.Diagnostics.Process.Start ("ExpLore"C:\\window ");    

C # Select a file, select a folder, open a file (or a folder)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.