Class TdbFile
- Namespace
- TdbIO
- Assembly
- TdbIO.dll
Entry point: tells the kind of a file and opens it as a TdbIO.TdbDocument.
public static class TdbFileInheritance
Inherited Members
Methods
DetectKind(string)
Tells the kind of a file from its first bytes (at most 64 KiB) and, for reports, its file name. Never throws for the content: data that is short, cut or not recognised gives TdbIO.TdbFileKind.Unknown.
public static TdbFileKind DetectKind(string path)Parameters
pathstring-
The file to examine.
Returns
- TdbFileKind
-
The kind of the file.
Exceptions
- ArgumentNullException
-
pathis null. - ArgumentException
-
pathis empty. - IOException
-
The file cannot be read.
- UnauthorizedAccessException
-
Access to the file is denied.
DetectKind(Stream, string?)
Tells the kind of the data from its first bytes (at most 64 KiB, read from the current position) and, for reports, the file name. A seekable stream is moved back to where it was; the stream is not disposed. Never throws for the content: data that is short, cut or not recognised gives TdbIO.TdbFileKind.Unknown.
public static TdbFileKind DetectKind(Stream stream, string? fileName = null)Parameters
streamStream-
A readable stream.
fileNamestring?-
The file name, used only to recognise reports (
.xsr), which have no signature.
Returns
- TdbFileKind
-
The kind of the data.
Exceptions
- ArgumentNullException
-
streamis null. - ArgumentException
-
streamis not readable. - IOException
-
The stream cannot be read.
Open(string, TdbReadOptions?)
Opens a file and reads it into the document of its kind.
public static TdbDocument Open(string path, TdbReadOptions? options = null)Parameters
pathstring-
The file to open.
optionsTdbReadOptions?-
Read options; null for the defaults.
Returns
- TdbDocument
-
The document; its type depends on TdbIO.TdbDocument.Kind.
Exceptions
- ArgumentNullException
-
pathis null. - ArgumentException
-
pathis empty. - InvalidDataException
-
The file is malformed, over a limit or not recognised.
- NotSupportedException
-
The file is recognised but not supported.
- IOException
-
The file cannot be read.
- UnauthorizedAccessException
-
Access to the file is denied.
Open(Stream, string?, TdbReadOptions?)
Reads the data from the current position to the end into the document of its kind. The stream need not be seekable and is not disposed.
public static TdbDocument Open(Stream stream, string? fileName = null, TdbReadOptions? options = null)Parameters
streamStream-
A readable stream.
fileNamestring?-
The file name, used only to recognise reports (
.xsr), which have no signature. optionsTdbReadOptions?-
Read options; null for the defaults.
Returns
- TdbDocument
-
The document; its type depends on TdbIO.TdbDocument.Kind.
Exceptions
- ArgumentNullException
-
streamis null. - ArgumentException
-
streamis not readable. - InvalidDataException
-
The data is malformed, over a limit or not recognised.
- NotSupportedException
-
The data is recognised but not supported.
- IOException
-
The stream cannot be read.