ReadAllText
ReadAllText
Returns the contents of a text file as a String.
Syntax
FileSystem.ReadAllText(File)
FileSystem.ReadAllText(File, Encoding)
Parameters
File |
String, input |
|
Name and path of the file to read. |
||
Encoding |
Character encoding to use in reading the file. Default is UTF-8 |
Remarks
Encoding |
||
ASCII |
Gets an encoding for the ASCII (7-bit) character set. |
|
Unicode |
Gets an encoding for the UTF-16 format using the little endian byte order. |
|
UTF32 |
Gets an encoding for the UTF-32 format using the little endian byte order. |
|
UTF7 |
Gets an encoding for the UTF-7 format. |
|
UTF8 |
Gets an encoding for the UTF-8 format. |
Examples
This example reads the contents of the specified file into a string and displays it in a message box:
Sub Main()
MsgBox FileSystem.ReadAllText("C:\Users\Public\My Directory\Test.txt")
End Sub
This example reads the contents of the specified ASCII file into a string and displays it in a message box:
Sub Main()
MsgBox FileSystem.ReadAllText("C:\Users\Public\My Directory\Test.txt", Encoding.ASCII)
End Sub