Table of Contents

Struct FileAttachment

Namespace
Kook
Assembly
Kook.Net.Core.dll

Represents a file attachment.

public struct FileAttachment : IDisposable
Implements
Inherited Members

Constructors

FileAttachment(Stream, string, AttachmentType)

Creates a file attachment from a stream.

public FileAttachment(Stream stream, string filename, AttachmentType type = AttachmentType.File)

Parameters

stream Stream

The stream to create the attachment from.

filename string

The name of the attachment.

type AttachmentType

The type of the attachment.

FileAttachment(string, string?, AttachmentType)

Create the file attachment from a file path.

public FileAttachment(string path, string? filename = null, AttachmentType type = AttachmentType.File)

Parameters

path string

The path to the file.

filename string

The name of the attachment.

type AttachmentType

The type of the attachment.

Remarks

This file path is NOT validated and is passed directly into a OpenRead(string).

Exceptions

ArgumentException

path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by GetInvalidPathChars().

ArgumentNullException

path is null.

PathTooLongException

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

NotSupportedException

path is in an invalid format.

DirectoryNotFoundException

The specified path is invalid, (for example, it is on an unmapped drive).

UnauthorizedAccessException

path specified a directory. -or- The caller does not have the required permission.

FileNotFoundException

The file specified in path was not found.

IOException

An I/O error occurred while opening the file.

FileAttachment(Uri, string, AttachmentType)

Create the file attachment from a URI.

public FileAttachment(Uri uri, string filename, AttachmentType type = AttachmentType.File)

Parameters

uri Uri

The URI of the file.

filename string

The name of the attachment.

type AttachmentType

The type of the attachment.

Remarks

This URI path will be validated before being passed into REST API. If the resource the URI points to is not stored on KOOK OSS, this constructor will throw an exception. Under this circumstance, please create asset in advance.

Exceptions

InvalidOperationException

The URI provided is not an asset on the KOOK OSS.

ArgumentException

The URI provided is blank.

See Also

Properties

FileName

Gets the filename.

public readonly string FileName { get; }

Property Value

string

Mode

Gets how this attachment will be operated.

public readonly CreateAttachmentMode Mode { get; }

Property Value

CreateAttachmentMode

Stream

Gets the stream containing the file content.

public readonly Stream? Stream { get; }

Property Value

Stream

Type

Gets the type of this attachment.

public readonly AttachmentType Type { get; }

Property Value

AttachmentType

Uri

Gets the URI of the file.

public readonly Uri? Uri { get; }

Property Value

Uri

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()