Common File Operations (3)

Source: Internet
Author: User

Common File Operations (3)

File class

Namespace: system. Io

Method. The static method is as follows:

Serial number Function Name Description
1 Appendalltext Append the specified string to the file. If the file does not exist, create the file.
2 Appendtext Create a streamwriter that appends the UTF-8-encoded text to an existing file.
3 Copy Copy an existing file to a new file.
4 Create Create a file in the specified path.
5 Createtext Creates or opens a file that is used to write UTF-8-encoded text.
6 Decrypt Decrypt the files encrypted by the current account using the encrypt method.
7 Delete Deletes a specified object. If the specified file does not exist, no exception is thrown.
8 Encrypt Encrypts a file so that only the account that encrypts the file can decrypt it.
9 Exists Determines whether the specified file exists.
10 Getaccesscontrol Obtains a filesecurity object that encapsulates the access control list (ACL) entries of the specified file.
11 Getattributes Obtain the fileattributes of the file in this path.
12 Getcreationtime Returns the creation date and time of the specified file or directory.
13 Getcreationtimeutc Returns the creation date and time of the specified file or directory. The format is Coordinated Universal Time (UTC ).
14 Getlastaccesstime Returns the date and time of the last access to the specified file or directory.
15 Getlastaccesstimeutc Returns the date and time of the last access to the specified file or directory. The format is Coordinated Universal Time (UTC ).
16 Getlastwritetime Returns the date and time when the specified file or directory was last written.
17 Getlastwirtetimeutc Returns the date and time when the specified file or directory was last written. The format is Coordinated Universal Time (UTC ).
18 Move Moves the specified file to a new location and provides the option to specify a new file name.
19 Open Open the filestream in the specified path.
20 Openread Open an existing file for reading.
21 Opentext Open an existing UTF-8 encoding text file for reading.
22 Openwrite Open an existing file for writing.
23 Readallbytes Open a file, read the file content into a string, and then close the file.
24 Readalllines Open a text file, read all the lines of the file into a string array, and then close the file.
25 Readalltext Open a text file, read all the lines of the file into a string, and then close the file.
26 Replace Replace the content of a specified file with the content of another file. This process deletes the original file and creates a backup of the replaced file.
27 Setaccesscontrol Applies the access control list (ACL) item described by the filesecurity object to the specified file.
28 Setattributes Sets the specified fileattributes of the file in the specified path.
29 Setcreationtime Set the date and time when the file was created.
30 Setcreationtimeutc Set the date and time when the file is created. The format is Coordinated Universal Time (UTC ).
31 Setlastaccesstime Set the date and time of the last access to the specified file.
32 Setlastaccesstimeutc Sets the date and time of the last object to be accessed. The format is Coordinated Universal Time (UTC ).
33 Setlastwritetime Specifies the date and time when the specified file was last written.
34 Setlastwritetimeutc Sets the date and time of the last specified file written. The format is Coordinated Universal Time (UTC ).
35 Writeallbytes Create a new file, write the specified byte array in it, and then close the file. If the target file already exists, rewrite the file.
36 Writealllines Create a new file, write the specified string in it, and then close the file. If the target file already exists, rewrite the file.
37 Writealltext Create a new file, write content to the file, and then close the file. If the target file already exists, rewrite the file.

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.