Reference
OpcFileInfo Members
Provides properties and instance methods for the opening of files and aids in the creation of OpcFileStream objects.
Reference
OpcFileInfo Members
- Type
- OpcFileInfo
- Namespace
- Opc.UaFx.Client
- Assembly
- Opc.UaFx.Advanced.dll
- Package
- Opc.UaFx.Advanced v2.59.0
- Also in
- Opc.UaFx.Client
Constructors
OpcFileInfo
| Overload | Description |
|---|---|
| OpcFileInfo( | Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the context specified. |
| OpcFileInfo( | Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the fileNodeId and accessed using the client specified. |
OpcFileInfo(OpcFileNodeContext)
Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the context specified.
public OpcFileInfo(OpcFileNodeContext context)Public Sub New(context As OpcFileNodeContext)Parameters
| Name | Type | Description |
|---|---|---|
context | Opc | The Opc |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The context is a null reference ( |
OpcFileInfo(OpcClient, OpcNodeId)
Initializes a new instance of the OpcFileInfo class, which acts as a wrapper for the file node identified by the fileNodeId and accessed using the client specified.
public OpcFileInfo(OpcClient client, OpcNodeId fileNodeId)Public Sub New(client As OpcClient, fileNodeId As OpcNodeId)Parameters
| Name | Type | Description |
|---|---|---|
client | OpcClient | The OpcClient to use when accessing the file node information. |
fileNodeId | OpcNodeId | The OpcNodeId of the file node to wrap. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The client or fileNodeId is a null reference ( |
Properties
CanUserWrite
Gets a value indicating whether the file is writable taking user access rights into account.
public bool CanUserWrite { get; }Public ReadOnly Property CanUserWrite As BooleanProperty value
The value true if the current file can be written by the current user; otherwise the value false.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
This property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
CanWrite
Gets a value indicating whether the file is writable.
public bool CanWrite { get; }Public ReadOnly Property CanWrite As BooleanProperty value
The value true if the current file can be written; otherwise the value false.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
This property does not take any user access rights into account, i.e. although the file is writable this may be restricted to a certain user / user group. The property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
Context
Gets the OpcFileNodeContext used to wrap and access the file node its information is to be provided by the OpcFileInfo.
public OpcFileNodeContext Context { get; }Public ReadOnly Property Context As OpcFileNodeContextProperty value
An instance of the OpcFileNodeContext class.
Exists
Gets a value indicating whether the file node represented exists.
public bool Exists { get; }Public ReadOnly Property Exists As BooleanProperty value
The value true if the file node exists; otherwise the value false if the file node does not exist.
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
The Exists property returns false if any error occurs while trying to determine if the specified file node exists. This can occur in situations that raise exceptions.
Length
Gets the size, in bytes, of the current file represented by the file node described.
public long Length { get; }Public ReadOnly Property Length As LongProperty value
The size of the file of the current file node in bytes.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
To get the latest value, call the Refresh method.
MimeType
Gets the media type of the current file represented by the file node described.
public string MimeType { get; }Public ReadOnly Property MimeType As StringProperty value
The media type of the file of the current file node based on RFC 2046.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
To get the latest value, call the Refresh method.
Name
Gets the name of the file node described.
public OpcName Name { get; }Public ReadOnly Property Name As OpcNameProperty value
The OpcName of the file node described.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
When first called, OpcFileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
Methods
AppendText
Creates a StreamWriter that appends text to the file represented by this instance of the OpcFileInfo.
public StreamWriter AppendText()Public Function AppendText() As StreamWriterReturns
A new instance of the StreamWriter class.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
This method returns a write-only OpcFileStream object with the mode set to AppendWrite.
Open
Opens a file in the specified mode.
public OpcFileStream Open(OpcFileMode mode)Public Function Open(mode As OpcFileMode) As OpcFileStreamParameters
| Name | Type | Description |
|---|---|---|
mode | OpcFileMode | A OpcFileMode member specifying the mode in which to open the file. |
Returns
A OpcFileStream opened in the specified mode.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
OpenRead
Creates a read-only OpcFileStream.
public OpcFileStream OpenRead()Public Function OpenRead() As OpcFileStreamReturns
A new read-only OpcFileStream object.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
This method returns a read-only OpcFileStream object with the mode set to Read.
OpenText
Creates a StreamReader with UTF8 encoding.
public StreamReader OpenText()Public Function OpenText() As StreamReaderReturns
A new StreamReader with UTF8 encoding.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
OpenWrite
Creates a write-only OpcFileStream.
public OpcFileStream OpenWrite()Public Function OpenWrite() As OpcFileStreamReturns
A write-only OpcFileStream object.
Exceptions
| Exception | Condition |
|---|---|
| Invalid | The file node described by the current OpcFileInfo object could not be found. |
Remarks
This method returns a write-only OpcFileStream object with the mode set to Write.
The stream created does not append the new content to the existing content. Instead, it overwrites the existing data with the new data. If you overwrite longer data (such as "This is a test of the OpenWrite method") with a shorter string (like "Second "), the file will contain a mix of the strings ("Second test of the OpenWrite method").
Refresh
Refreshes the state and information of the OpcFileInfo object.
public void Refresh()Public Sub Refresh()Remarks
The method takes a snapshot of the file node.
Calls must be made to Refresh before attempting to get any information, or the information will be outdated.
ToString
Returns the OpcNodeId or the Value of the file node described.
public override string ToString()Public Overrides Function ToString() As StringReturns
A string representing the file node described.
Overrides

