Openfiledialog and savefiledialog are commonly used for encoding, conversation box usage, and obtain the path of special system files.

Source: Internet
Author: User

. NET FrameworkMedium Including voice boxes

1. commondiaolog

Filedialog

Openfiledialog

You can configure to select only one or more files to be opened by selecting the primary and secondary nodes.

Savefiledialog

Specify the file name and path for the file to be saved.

Folerbrowserdialog

Select an option and configure a project.. Net
2.0.

Colordialog

Used for Color Selection

Fontdialog

AllWindowsFonts, fonts, and fonts, as well as the effect of different fonts, in order to select the fonts.

Pagesetupdialog

Configure the distance between two shards.

Printdialog

Used to select a printer and set the printing options

2. Form

Printpreviewdialog

One way to print the rows on the screen.


3. commondialogDefines the following table methods and events

Common examples and events

Showdialog ()

Shows a universal conversation box

Reset ()

Each derived conversation box has two rows.Reset() Method, which sets all semantics of the conversation box to their silence values

Helprequest

For exampleHelpWhen you press the hour, the event will be triggered.

CommondialogIt is the base class of the conversation box, so all the usage methods of the conversation box are similar.Showdialog ()Used by the RegionRundialog() The example method is used to show the conversation box and use the information of the interaction operation between the user and the conversation box to return at most oneDialogresultExample. On the other hand,Reset() Set the semantics of the conversation boxes to their values.



OpenfiledialogCommon adequacy

Title

Topic

Initialdirectory

The initial target

Filter

Set the delimiter character

Filterindex

Optimize specifies the selected values in the list box. Its value is based on1.

Validatenames

Check whether the file name entered by using the Delimiter is valid. Invalid file sentence inclusion"",/Or: metacharacters

Checkfileexist

The validity of the certificate. It is deemed by defaultTrue

Checkpathexists

The token is valid. It is assumed thatTrue

ShowHelp

Show Help Information

Multiselect

Select multiple files

under the conditions of tacit understanding: the dialog box will be used to open the object that was last opened when the Program was used. Windows the general conversation box uses the notebooks table to locate the last opened file name

filter set the file to pass through the timer
This defines the types of files that can be selected by the user. The character string of the inner of the statement is as follows:
text documents (*. TXT) | *. TXT | all files | *. *
the timer can be divided into multiple parts, each part is separated by a parallel bar character (|) . The sum of data in each part is an even number. The first string defines the text to be displayed in the list box, and the second character is used to specify the extension name of the file to be displayed in the conversation box. For example, text documents (*. TXT) | *. TXT , used as "text documents (*. TXT) " and " *. TXT " two parts, with " | " separated. filter the reserved value is a reserved string. May be blank before and after the timer.

ValidatenamesValidity token query:
Check whether the file name entered by using the Delimiter is valid. WhenTrueYou can useCheckfileexistAndCheckpathexistsOther validity certificates are provided.

ShowHelpHelp:
OpenfiledialogIt provides a help-based press. In the case of tacit opinion, it is impossible to press the press button.ShowHelpForTrueWhen. You can alsoHelprequestAdd an event processing program, which is used to show help information for users.

dialogresult result:
openfiledialog class showdialog () the method returns a dialogresult token. This parameter defines members abort , cancel , ignore , NO , none , OK , retry and Yes .
none it is a default value, set this value as long as there is no relation between users.
savefiledialog only dialogresult. OK and dialogresult. cancel

MultiselectSelect multiple files:
WhenMultiselectAttribute settingsTrueYou can use hosts to select multiple files,FilenamesThe first string in the Data Group is the last selected file.FilenmeAttention always includes the name of the last selected file.


These features apply to the following features on the interface:


SavefiledialogCommon adequacy

Addextension

Whether to automatically add the display name to the name of the file that is imported with the display name. Mo believes thatTrueIf the user has already entered a file development name, no other development name will be added.

Checkfileexist

The validity of the certificate. It is deemed by defaultFalse

Checkpathexists

The token is valid. It is assumed thatTrue

Createprompt

Ask whether to split a new file

Overwriteprompt

Whether to overwrite existing files.


if the member is not listed in the Development name, use defaultext variable name of the file. If this encoding is null, use the filter name of the predefined file. If filter and defaultext defaultext .

Usage of the conversation box:
1) create a new example for the frame type.
2) configuration and selection
3) the consumer uses the showdialog () method to display the conversation box and waits for the response
4) action after the preset response

For example:

// 1,Create a new example for the frame type.
Openfiledialog DLG =   New Openfiledialog ();
// 2,Configuration and selection
DLG. Title =   " Sample " ;
DLG. showreadonly =   True ;
// 3, Dialog Box
If (DLG. showdialog () = Dialogresult. OK)
{
// 4,Action after the preset response
String Filename = DLG. filename;
}

others:
obtain the path of the special system file:
retrieve the specified system file. You can use system. the condition Condition Method getfolderpath () of environment ().
environment. specialfolder defines the path of the system category

code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/

--> // obtain the target file in the system.
string dir = environment. getfolderpath (environment. specialfolder. templates);

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.