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
StreamThe stream to create the attachment from.
fileName
stringThe name of the attachment.
description
stringThe description of the attachment.
isSpoiler
boolWhether or not the attachment is a spoiler.
isThumbnail
boolWhether 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
stringThe path to the file.
fileName
stringThe name of the attachment.
description
stringThe description of the attachment.
isSpoiler
boolWhether or not the attachment is a spoiler.
isThumbnail
boolWhether 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
FileName
Gets or sets the filename.
public string FileName { readonly get; set; }
Property Value
IsSpoiler
Gets or sets whether this file should be marked as a spoiler.
public bool IsSpoiler { readonly get; set; }
Property Value
IsThumbnail
Gets or sets if this file should be a thumbnail for a media channel post.
public bool IsThumbnail { readonly get; set; }
Property Value
Stream
Gets the stream containing the file content.
public readonly Stream Stream { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()