Επεξεργασία

Κοινή χρήση μέσω


FileSystem.FileGet Method

Definition

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

Overloads

FileGet(Int32, Array, Int64, Boolean, Boolean)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, String, Int64, Boolean)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, ValueType, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Single, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int64, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int32, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Decimal, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Double, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, DateTime, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Char, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Byte, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Boolean, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Int16, Int64)

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

FileGet(Int32, Array, Int64, Boolean, Boolean)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref Array Value, long RecordNumber = -1, bool ArrayIsDynamic = false, bool StringIsFixedLength = false);
static member FileGet : int * Array * int64 * bool * bool -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Array, Optional RecordNumber As Long = -1, Optional ArrayIsDynamic As Boolean = false, Optional StringIsFixedLength As Boolean = false)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Array

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

ArrayIsDynamic
Boolean

Optional. Applies only when writing an array. Specifies whether the array is to be treated as dynamic and whether an array descriptor describing the size and bounds of the array is necessary.

StringIsFixedLength
Boolean

Optional. Applies only when writing a string. Specifies whether to write a two-byte descriptor for the string that describes the length. The default is False.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the starting of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, String, Int64, Boolean)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref string Value, long RecordNumber = -1, bool StringIsFixedLength = false);
static member FileGet : int * string * int64 * bool -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As String, Optional RecordNumber As Long = -1, Optional StringIsFixedLength As Boolean = false)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
String

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

StringIsFixedLength
Boolean

Optional. Applies only when writing a string. Specifies whether to write a two-byte descriptor for the string that describes the length. The default is False.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, ValueType, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref ValueType Value, long RecordNumber = -1);
static member FileGet : int * ValueType * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As ValueType, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
ValueType

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Single, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref float Value, long RecordNumber = -1);
static member FileGet : int * single * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Single, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Single

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Int64, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref long Value, long RecordNumber = -1);
static member FileGet : int * int64 * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Long, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int64

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Int32, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref int Value, long RecordNumber = -1);
static member FileGet : int * int * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Integer, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int32

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Decimal, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref decimal Value, long RecordNumber = -1);
static member FileGet : int * decimal * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Decimal, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Decimal

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Double, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref double Value, long RecordNumber = -1);
static member FileGet : int * double * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Double, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Double

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using theFileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, DateTime, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref DateTime Value, long RecordNumber = -1);
static member FileGet : int * DateTime * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As DateTime, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
DateTime

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file with FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function,FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Char, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref char Value, long RecordNumber = -1);
static member FileGet : int * char * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Char, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Char

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file with FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Byte, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref byte Value, long RecordNumber = -1);
static member FileGet : int * byte * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Byte, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Byte

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file with FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used. Then the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Boolean, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref bool Value, long RecordNumber = -1);
static member FileGet : int * bool * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Boolean, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Boolean

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file with FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using theFileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to

FileGet(Int32, Int16, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open disk file into a variable. The My feature gives you better productivity and performance in file I/O operations than FileGet. For more information, see FileSystem.

public static void FileGet (int FileNumber, ref short Value, long RecordNumber = -1);
static member FileGet : int * int16 * int64 -> unit
Public Sub FileGet (FileNumber As Integer, ByRef Value As Short, Optional RecordNumber As Long = -1)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int16

Required. Valid variable name into which data is read.

RecordNumber
Int64

Optional. Record number (Random mode files) or byte number (Binary mode files) at which reading starts.

Exceptions

RecordNumber < 1 and not equal to -1.

File mode is invalid.

Remarks

FileGet is valid only in Random and Binary mode.

Data read with FileGet is usually written to a file by using FilePut.

The first record or byte in a file is at position 1, the second record or byte is at position 2, and so on. If you omit RecordNumber, the next record or byte following the last FileGet or FilePut function (or pointed to by the last Seek function) is read.

Important

When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic source file.

Random Mode

For files opened in Random mode, the following rules apply:

  • If the length of the data being read is less than the length specified in the RecordLength clause of the FileOpen function, FileGet reads subsequent records on record-length boundaries. The space between the end of one record and the start of the next record is padded with the existing contents of the file buffer. Because the amount of padding data cannot be determined with any certainty, it is generally a good idea to have the record length match the length of the data being read.

  • By default, if the variable being read into is a string, FileGet reads a two-byte descriptor that contains the string length and then reads the data that goes into the variable. Therefore, the record length specified by the RecordLength clause of the FileOpen function must be at least two bytes greater than the actual length of the string. Visual Basic 6.0 and earlier versions support fixed-length strings; when put to a file, the length descriptor is not written. If you want to read a string without the descriptor, you should pass True to the StringIsFixedLength parameter, and the string you read into should be the correct length.

  • If the variable being read into is an array, you can choose whether to read a descriptor for the size and dimension of the array. To write the descriptor, set the ArrayIsDynamic parameter to True. When reading the array, you have to match the way the array was written. If it was written with the descriptor, you have to read the descriptor. If the descriptor is not used, the size and bounds of the array passed into FileGet determine what to read.

    The descriptor specifies the rank of the array, the size, and the lower bounds for each rank. Its length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength parameter in the FileOpen function must be greater than or equal to the sum of all the bytes required to write the array data and the array descriptor. For example, the following array declaration requires 218 bytes when the array is written to disk.

    Dim MyArray(4, 9) As Integer
    

    The 218 bytes are distributed as follows:

    • 18 bytes for the descriptor: (2 + 8 * 2)

    • 200 bytes for the data: (5 * 10 * 4).

  • If the variable being read into is any other type of variable (not a variable-length string or an object), FileGet reads only the variable data. The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the length of the data being read.

  • FileGet reads elements of structures as if each were being read individually, except that there is no padding between elements. On disk, a dynamic array in a user-defined type (written with FilePut) is prefixed by a descriptor whose length equals 2 plus 8 times the number of dimensions: (2 + 8 * NumberOfDimensions). The record length specified by the RecordLength clause in the FileOpen function must be greater than or equal to the sum of all the bytes required to read the individual elements. This includes any arrays and their descriptors. The VBFixedString attribute can be applied to string fields in the structures to indicate the size of a string when written to disk.

Binary Mode

For files opened in Binary mode, most of the Random mode rules apply, with some exceptions. The following rules for files opened in Binary mode differ from the rules for Random mode:

  • The RecordLength clause in the FileOpen function has no effect. FileGet reads all variables from disk contiguously; that is, without padding between records.

  • For any array other than an array in a structure, FileGet reads only the data. No descriptor is read.

  • FileGet reads variable-length strings that are not elements of structures without expecting the two-byte length descriptor. The number of bytes read equals the number of characters already in the string.

    Important

    Reading from a file by using the FileGet function requires Read access from the FileIOPermissionAccess enumeration.

See also

Applies to