Close filestream in SendFile(filePath) after sending

This commit is contained in:
RogueException
2015-12-30 14:45:26 -04:00
parent 72f1e6161a
commit fade4496b0

View File

@@ -357,8 +357,11 @@ namespace Discord
return msg;
}
public Task<Message> SendFile(string filePath)
=> SendFile(Path.GetFileName(filePath), File.OpenRead(filePath));
public async Task<Message> SendFile(string filePath)
{
using (var stream = File.OpenRead(filePath))
return await SendFile(Path.GetFileName(filePath), stream);
}
public async Task<Message> SendFile(string filename, Stream stream)
{
if (filename == null) throw new ArgumentNullException(nameof(filename));