Msdn open file




















A FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.

NET Framework and. NET Core versions older than 2. You can query for invalid characters by using the GetInvalidPathChars method. The following code example creates a temporary file and writes some text to it. The example then opens the file, using T:System. Open; that is, if the file did not already exist, it would not be created. The path parameter is permitted to specify relative or absolute path information.

Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory. An object that describes optional FileStream parameters to use. The asterisk is a wildcard that represents any combination of valid file name characters.

The dialog box displays only those files that match the pattern. To specify multiple patterns for the same description, you must use a semicolon ; to separate the patterns.

Note that space characters in the pattern string can produce unexpected results. The following code fragment specifies two filters. The filter with the "Source" description has two patterns. If the user selects this filter, the dialog box displays only files that have the. C and. CXX extensions. Note, in the C programming language, a string enclosed in double quotes is null-terminated.

The first filter in the buffer has index 1, the second 2, and so on. If the user changes the filter while using the dialog box, the nFilterIndex member is set to the index of the selected filter on return.

You can create a custom filter by setting the lpstrCustomFilter member to the address of a buffer that contains a single filter, and by setting the nMaxCustFilter member to the size of the buffer, in characters or bytes.

The dialog box always places the custom filter at the beginning of the list of filters and, on return, always updates the pattern part of the filter with the pattern from the filter selected by the user.

For Explorer-style dialog boxes, the default extension may change if the user selects a different filter. The return value of the hook procedure indicates whether the dialog box should display the item in the folder's item list.

Except as noted, the information in this section applies to both Explorer-style and old-style Open and Save As dialog boxes. The dialog box automatically validates file names typed by the user to ensure that the names contain only valid characters. If this flag is set and the user chooses to create a new file, the dialog box closes, and the function returns the specified name.

Otherwise, the dialog box remains open. By default, the dialog box creates a zero-length test file to determine whether a new file can be created in the selected directory. If you enable a hook procedure, the dialog box notifies your hook procedure when a network sharing violation occurs for the file name specified by the user. In this case, the dialog box returns the name of the link file rather than the name of the file referenced by the link file.

You can customize an Open or Save As dialog box by providing a hook procedure, a custom template, or both. However, the Explorer-style and old-style versions of the dialog boxes differ in their use of custom templates and hook procedures. The default title for both Explorer-style and old-style dialog boxes is either " Open " or " Save As. These registry entries affect only the dialog boxes displayed for the user associated with the registry hive.

To hide features of Explorer-style Open and Save As dialog boxes, an administrator can set the values in the following table under this subkey:. The contents of the Places bar are determined by the contents of the following subkey:. You can customize an Explorer-style Open or Save As dialog box by providing a hook procedure, a custom template, or both.

If you provide a hook procedure for an Explorer-style dialog box, the system creates a dialog box that is a child of the default dialog box. The hook procedure acts as the dialog procedure for the child dialog box. This child dialog box is based on the custom template, or on a default template if none is provided. For more information, see Explorer-Style Custom Templates.

An Explorer-style hook procedure receives a variety of messages while the dialog box is open. These include the following:. In addition, there is a set of messages that you can send to an Explorer-style dialog box to get information or to control the behavior and appearance of the dialog box. You can use some of these messages to control the behavior of the dialog box. In response to this message, the hook procedure can use the SetWindowLong function to reject the selected name and force the dialog box to remain open.

The code member in the header of this structure contains one of the following notification messages. To retrieve information about the status of the dialog box or to control the behavior and appearance of the dialog box, the hook procedure can send the following messages to the dialog box. Typically, if you provide additional controls, you must also provide an Explorer-style hook procedure to process messages for the new controls. To make room for the new controls, the system expands the default dialog box by the width and height of the custom dialog box.

Overwriting a file of the same name is not allowed. Copy String, String, Boolean. Overwriting a file of the same name is allowed. Create String. Create String, Int Creates or overwrites a file in the specified path, specifying a buffer size. Create String, Int32, FileOptions. CreateSymbolicLink String, String. CreateText String. Decrypt String. Delete String. Encrypt String. Encrypts a file so that only the account used to encrypt the file can decrypt it.

Exists String. GetAccessControl String. GetAttributes String. GetCreationTime String. Returns the creation date and time of the specified file or directory. GetCreationTimeUtc String. GetLastAccessTime String. Returns the date and time the specified file or directory was last accessed. GetLastWriteTime String. Returns the date and time the specified file or directory was last written to.

Move String, String. Moves a specified file to a new location, providing the option to specify a new file name. Move String, String, Boolean. Open String, FileMode. Open String, FileStreamOptions. OpenRead String. OpenText String. OpenWrite String. ReadAllBytes String. Opens a binary file, reads the contents of the file into a byte array, and then closes the file.

ReadAllLines String. Opens a text file, reads all lines of the file, and then closes the file. ReadAllLines String, Encoding. Opens a file, reads all lines of the file with the specified encoding, and then closes the file.

Asynchronously opens a text file, reads all lines of the file, and then closes the file. ReadAllText String. Opens a text file, reads all the text in the file, and then closes the file. ReadAllText String, Encoding. Opens a file, reads all text in the file with the specified encoding, and then closes the file. Asynchronously opens a text file, reads all the text in the file, and then closes the file.

ReadLines String. ReadLines String, Encoding. Replace String, String, String.



0コメント

  • 1000 / 1000