Table of Contents

Struct FileAttachment

Namespace
Discord
Assembly
Discord.Net.Core.dll

Represents an outgoing file attachment used to send a file to discord.

public struct FileAttachment : IDisposable
Implements
Inherited Members

Constructors

FileAttachment(Stream, string, string, bool, bool, double?, byte[])

Creates a file attachment from a stream.

public FileAttachment(Stream stream, string fileName, string description = null, bool isSpoiler = false, bool isThumbnail = false, double? durationSeconds = null, byte[] waveform = null)

Parameters

stream Stream

The stream to create the attachment from.

fileName string

The name of the attachment.

description string

The description of the attachment.

isSpoiler bool

Whether or not the attachment is a spoiler.

isThumbnail bool

Whether or not this attachment should be a thumbnail for a media channel post.

durationSeconds double?
waveform byte[]

FileAttachment(string, string, string, bool, bool, double?, byte[])

Create the file attachment from a file path.

public FileAttachment(string path, string fileName = null, string description = null, bool isSpoiler = false, bool isThumbnail = false, double? durationSeconds = null, byte[] waveform = null)

Parameters

path string

The path to the file.

fileName string

The name of the attachment.

description string

The description of the attachment.

isSpoiler bool

Whether or not the attachment is a spoiler.

isThumbnail bool

Whether or not this attachment should be a thumbnail for a media channel post.

durationSeconds double?
waveform byte[]

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.

Properties

Description

Gets or sets the description of the file.

public string Description { readonly get; set; }

Property Value

string

DurationSeconds

Gets or sets the duration of a voice message. null if the attachment is not a voice message.

public double? DurationSeconds { readonly get; set; }

Property Value

double?

FileName

Gets or sets the filename.

public string FileName { readonly get; set; }

Property Value

string

IsSpoiler

Gets or sets whether this file should be marked as a spoiler.

public bool IsSpoiler { readonly get; set; }

Property Value

bool

IsThumbnail

Gets or sets if this file should be a thumbnail for a media channel post.

public bool IsThumbnail { readonly get; set; }

Property Value

bool

Stream

Gets the stream containing the file content.

public readonly Stream Stream { get; }

Property Value

Stream

Waveform

Gets or sets bytearray representing a sampled waveform. null if the attachment is not a voice message.

public byte[] Waveform { readonly get; set; }

Property Value

byte[]

Methods

Dispose()

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

public void Dispose()