May 10, 2010 My VC 2010 Express installation is stuck in offline help mode, probably because I clicked 'No' in the dialogue box that pops up when you first try to access the help system. However, there is no option to toggle online vs. Offline help modes in the Express.
-->Definition
Opens a file for input or output. The
My
feature gives you better productivity and performance in file I/O operations than FileOpen
. For more information, see FileSystem.Parameters
- FileNumber
- Int32
Required. Any valid file number. Use the
FreeFile
function to obtain the next available file number.- FileName
- String
Required. A string expression that specifies a file name - may include directory or folder, and drive.
- Mode
- OpenMode
Required. Enumeration specifying the file mode:
Append
, Binary
, Input
, Output
, or Random
. For more information, see OpenMode .- Access
- OpenAccess
Optional. Enumeration specifying the operations permitted on the open file:
Read
, Write
, or ReadWrite
. Defaults to ReadWrite
. For more information, see OpenAccess .- Share
- OpenShare
Optional. Enumeration specifying the operations not permitted on the open file by other processes:
Shared
, Lock Read
, Lock Write
, and Lock Read Write
. Defaults to Lock Read Write
. For more information, see OpenShare .- RecordLength
- Int32
Optional. Number less than or equal to 32,767 (bytes). For files opened for random access, this value is the record length. For sequential files, this value is the number of characters buffered.
Exceptions
Record length is negative (and not equal to -1).
FileName
is already open, or FileName
is invalid.Examples
This example illustrates various uses of the
FileOpen
function to enable input and output to a file.The following code opens the file
TestFile
in Input
mode.This example opens the file in
Binary
mode for writing operations only.The following example opens the file in
Random
mode. The file contains records of the structure Person
.This code example opens the file in
Output
mode; any process can read or write to file.This code example opens the file in
Binary
mode for reading; other processes cannot read file.Remarks
The
FileOpen
function is provided for backward compatibility and may affect performance. For non-legacy applications, the My.Computer.FileSystem
object provides better performance. For more information, see File Access with Visual Basic.You must open a file before any I/O operation can be performed on it.
FileOpen
allocates a buffer for I/O to the file and determines the mode of access to use with the buffer.Important
When writing to a file, an application may have to create a file, if the file to which it is trying to write does not exist. To do so, it needs permission for the directory in which the file is to be created. However, if the file specified by
FileName
does exist, the application needs Write
permission only to the file itself. Wherever possible, to help improve security, create the file during deployment and grant Write
permission to that file only, instead of to the whole directory. To help improve security, write data to user directories instead of to the root directory or the Program Files directory.The channel to open can be found by using the
FreeFile()
function.Important
The
FileOpen
function requires Read
access from the FileIOPermissionAccess
enumeration, which may affect its execution in partial trust situations. For more information, see FileIOPermissionAccess enumeration.Applies to
See also
![Visual basic 2010 express offline model Visual basic 2010 express offline model](https://i.ytimg.com/vi/fbrUBqOaii8/maxresdefault.jpg)
This section provides reference information for various aspects of the Visual Basic language.
In This Section
Typographic and Code Conventions
Summarizes the way that keywords, placeholders, and other elements of the language are formatted in the Visual Basic documentation.
Summarizes the way that keywords, placeholders, and other elements of the language are formatted in the Visual Basic documentation.
Visual Basic Runtime Library Members
Lists the classes and modules of the Microsoft.VisualBasic namespace, with links to their member functions, methods, properties, constants, and enumerations.
Lists the classes and modules of the Microsoft.VisualBasic namespace, with links to their member functions, methods, properties, constants, and enumerations.
Keywords
Lists all Visual Basic keywords and provides links to more information.
Lists all Visual Basic keywords and provides links to more information.
Attributes (Visual Basic)
Documents the attributes available in Visual Basic.
Documents the attributes available in Visual Basic.
Constants and Enumerations
Documents the constants and enumerations available in Visual Basic.
Documents the constants and enumerations available in Visual Basic.
Data Types
Documents the data types available in Visual Basic.
Documents the data types available in Visual Basic.
Directives
Documents the compiler directives available in Visual Basic.
Documents the compiler directives available in Visual Basic.
Functions
Documents the run-time functions available in Visual Basic.
Documents the run-time functions available in Visual Basic.
Modifiers
Lists the Visual Basic run-time modifiers and provides links to more information.
Lists the Visual Basic run-time modifiers and provides links to more information.
Modules
Documents the modules available in Visual Basic and their members.
Documents the modules available in Visual Basic and their members.
Nothing
Describes the default value of any data type.
Describes the default value of any data type.
Objects
Documents the objects available in Visual Basic and their members.
Documents the objects available in Visual Basic and their members.
Operators
Documents the operators available in Visual Basic.
Documents the operators available in Visual Basic.
![Visual Basic 2010 Express Offline Mode Visual Basic 2010 Express Offline Mode](/uploads/1/2/6/3/126339449/383176567.gif)
Properties
Documents the properties available in Visual Basic.
Documents the properties available in Visual Basic.
Queries
Provides reference information about using Language-Integrated Query (LINQ) expressions in your code.
Provides reference information about using Language-Integrated Query (LINQ) expressions in your code.
Statements
Documents the declaration and executable statements available in Visual Basic.
Documents the declaration and executable statements available in Visual Basic.
XML Comment Tags
Describes the documentation comments for which IntelliSense is provided in the Visual Basic Code Editor.
Describes the documentation comments for which IntelliSense is provided in the Visual Basic Code Editor.
XML Axis Properties
Provides links to information about using XML axis properties to access XML directly in your code.
Provides links to information about using XML axis properties to access XML directly in your code.
XML Literals
Provides links to information about using XML literals to incorporate XML directly in your code.
Provides links to information about using XML literals to incorporate XML directly in your code.
Error Messages
Provides a listing of Visual Basic compiler and run-time error messages and help on how to handle them.
Provides a listing of Visual Basic compiler and run-time error messages and help on how to handle them.
Related Sections
Visual Basic Command-Line Compiler
Describes how to use the command-line compiler as an alternative to compiling programs from within the Visual Studio integrated development environment (IDE).
Describes how to use the command-line compiler as an alternative to compiling programs from within the Visual Studio integrated development environment (IDE).