diff --git a/TelegramBotBase/Sessions/DeviceSession.cs b/TelegramBotBase/Sessions/DeviceSession.cs index bc6c697..0aad579 100644 --- a/TelegramBotBase/Sessions/DeviceSession.cs +++ b/TelegramBotBase/Sessions/DeviceSession.cs @@ -501,6 +501,34 @@ namespace TelegramBotBase.Sessions return m; } + /// + /// Generates a Textfile from scratch with the specified encoding. (Default is UTF8) + /// + /// + /// + /// Default is UTF8 + /// + /// + /// + /// + /// + public async Task SendTextFile(String filename, String textcontent, Encoding encoding = null, String caption = "", ButtonForm buttons = null, int replyTo = 0, bool disableNotification = false) + { + encoding = encoding ?? Encoding.UTF8; + + var ms = new MemoryStream(); + var sw = new StreamWriter(ms, encoding); + + sw.Write(textcontent); + sw.Flush(); + + var content = ms.ToArray(); + + var m = await SendDocument(filename, content, caption, buttons, replyTo, disableNotification); + + return m; + } + /// /// Sends an document ///