# OpcFileInfo Members

> Reference: Provides a default implementation of the IOpcFileInfo interface representing a FileInfo for the use in OPC UA.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcFileInfo</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Constructors

### OpcFileInfo

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [OpcFileInfo(string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/members#opcfileinfo-system-string) | Initializes a new instance of the [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/) class with the `filePath` specified. |
| [OpcFileInfo(FileInfo)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/members#opcfileinfo-system-io-fileinfo) | Initializes a new instance of the [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/) class with the [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) to use as the `underlyingFileInfo`. |

#### OpcFileInfo(string)

Initializes a new instance of the [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/) class with the `filePath` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcFileInfo(string filePath)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(filePath As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `filePath` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The fully qualified path or the relative path to the file to represent. |

#### OpcFileInfo(FileInfo)

Initializes a new instance of the [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/) class with the [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) to use as the `underlyingFileInfo`.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcFileInfo(FileInfo underlyingFileInfo)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(underlyingFileInfo As FileInfo)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `underlyingFileInfo` | [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) | The underlying [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) to use. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `underlyingFileInfo` is a null reference (Nothing in Visual Basic). |

## Properties

### Exists

Gets a value indicating whether a file exists.

<div class="api-signature" data-lang="csharp">

```csharp
public bool Exists { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Exists As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the file exists; false if the file does not exist.

**Implements**

[Exists](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#exists)

### IsReadOnly

<span class="api-meta">virtual</span>

Gets or sets a value that determines if the current file is read only.

<div class="api-signature" data-lang="csharp">

```csharp
public virtual bool IsReadOnly { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Overridable ReadOnly Property IsReadOnly As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the current file is read only; otherwise the value false.

**Implements**

[IsReadOnly](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#isreadonly)

### Length

Gets the size, in bytes, of the current file.

<div class="api-signature" data-lang="csharp">

```csharp
public long Length { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Length As Long
```

</div>

**Property value**

[Int64](https://learn.microsoft.com/dotnet/api/system.int64)

The size of the current file in bytes.

**Implements**

[Length](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#length)

### UnderlyingFileInfo

Gets the underlying [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) used by the current [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/).

<div class="api-signature" data-lang="csharp">

```csharp
public FileInfo UnderlyingFileInfo { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property UnderlyingFileInfo As FileInfo
```

</div>

**Property value**

[FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo)

The instance of the [FileInfo](https://learn.microsoft.com/dotnet/api/system.io.fileinfo) class used by the current [OpcFileInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfileinfo/).

## Methods

### GetMimeType

Determines the internet media type (mime- or content-type) of the file.

<div class="api-signature" data-lang="csharp">

```csharp
public string GetMimeType()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function GetMimeType() As String
```

</div>

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The type name according to the specification of multipurpose internet mail extensions (MIME) of the file represented.

**Implements**

[GetMimeType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#getmimetype)

### Open

<span class="api-meta">virtual</span>

Opens a file in the specified mode.

<div class="api-signature" data-lang="csharp">

```csharp
public virtual Stream Open(OpcFileMode mode)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Overridable Function Open(mode As OpcFileMode) As Stream
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `mode` | [OpcFileMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/) | A [OpcFileMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcfilemode/) value specifying the mode in which to open the file. |

**Returns**

[Stream](https://learn.microsoft.com/dotnet/api/system.io.stream)

A file opened in the specified mode.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The file `mode` specified is invalid. |

**Implements**

[Open](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#open)

### OpenCore

<span class="api-meta">protected · virtual · since v2.17</span>

Opens the underlying file info with the specified mode, access, and share.

<div class="api-signature" data-lang="csharp">

```csharp
protected virtual Stream OpenCore(
    FileMode fileMode,
    FileAccess fileAccess,
    FileShare fileShare)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overridable Function OpenCore(
    fileMode As FileMode,
    fileAccess As FileAccess,
    fileShare As FileShare) As Stream
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `fileMode` | [FileMode](https://learn.microsoft.com/dotnet/api/system.io.filemode) | A [FileMode](https://learn.microsoft.com/dotnet/api/system.io.filemode) constant specifying the mode (for example, Open or Append) in which to open the file. |
| `fileAccess` | [FileAccess](https://learn.microsoft.com/dotnet/api/system.io.fileaccess) | A [FileAccess](https://learn.microsoft.com/dotnet/api/system.io.fileaccess) constant specifying whether to open the file with Read, Write, or ReadWrite file access. |
| `fileShare` | [FileShare](https://learn.microsoft.com/dotnet/api/system.io.fileshare) | A [FileShare](https://learn.microsoft.com/dotnet/api/system.io.fileshare) constant specifying the type of access other FileStream objects have to this file. |

**Returns**

[Stream](https://learn.microsoft.com/dotnet/api/system.io.stream)

A [FileStream](https://learn.microsoft.com/dotnet/api/system.io.filestream) object opened with the specified mode, access, and sharing options.

### Refresh

Refreshes the state of the object.

<div class="api-signature" data-lang="csharp">

```csharp
public void Refresh()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Refresh()
```

</div>

**Exceptions**

| Exception | Condition |
|---|---|
| [IOException](https://learn.microsoft.com/dotnet/api/system.io.ioexception) | A device such as a disk drive is not ready. |

**Implements**

[Refresh](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcfileinfo/members#refresh)
