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)

Creates a file attachment from a stream.

public FileAttachment(Stream stream, string fileName, string description = null, bool isSpoiler = false, bool isThumbnail = false)

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.

FileAttachment(string, string, string, bool, bool)

Create the file attachment from a file path.

public FileAttachment(string path, string fileName = null, string description = null, bool isSpoiler = false, bool isThumbnail = false)

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.

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

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

Methods

Dispose()

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

public void Dispose()