Struct FileAttachment
- Namespace
- HeyBox
- Assembly
- HeyBox.Net.Core.dll
表示一个文件附件。
public struct FileAttachment : IDisposable
- Implements
- Inherited Members
Constructors
FileAttachment(Stream, string, AttachmentType, Size?)
通过流创建附件。
public FileAttachment(Stream stream, string filename, AttachmentType type = AttachmentType.Image, Size? imageSize = null)
Parameters
stream
Stream创建附件所使用的流。
filename
string文件名。
type
AttachmentType附件的类型。
imageSize
Size?图片附件的图像尺寸。
FileAttachment(string, string?, AttachmentType, Size?)
通过文件路径创建附件。
public FileAttachment(string path, string? filename = null, AttachmentType type = AttachmentType.Image, Size? imageSize = null)
Parameters
path
string文件的路径。
filename
string文件名。
type
AttachmentType附件的类型。
imageSize
Size?图片附件的图像尺寸。
Remarks
此构造函数不会校验文件路径的格式,path
的值将会直接传递给
OpenRead(string) 方法。
- See Also
FileAttachment(Uri, string, AttachmentType, Size?)
通过 URL 创建附件。
public FileAttachment(Uri uri, string filename, AttachmentType type = AttachmentType.Image, Size? imageSize = null)
Parameters
uri
Uri文件的 URL。
filename
string文件名。
type
AttachmentType附件的类型。
imageSize
Size?图片附件的图像尺寸。
Remarks
URL 应该是指向黑盒语音服务器上的资源的 URL。如果传入的网络地址不是指向黑盒语音服务器上的资源的 URL, 虽然此构造函数不会引发异常,但在发送消息时可能会引发异常。此时,网络资源应先通过转存至黑盒语音服务器上,再使用此构造函数。
- See Also
Properties
Filename
获取此附件的文件名。
public readonly string Filename { get; }
Property Value
ImageSize
获取或设置图片附件的图像尺寸。
public Size? ImageSize { readonly get; set; }
Property Value
- Size?
Mode
获取创建此文件附件的方式。
public readonly CreateAttachmentMode Mode { get; }
Property Value
Stream
获取包含文件内容的流。
public readonly Stream? Stream { get; }
Property Value
Type
获取此附件的类型。
public readonly AttachmentType Type { get; }
Property Value
Uri
获取指向文件的 URL。
public readonly Uri? Uri { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()