J
J
judywb2020-01-02 22:27:32
C++ / C#
judywb, 2020-01-02 22:27:32

How to send txt file by telegram bot?

I have path to txt file. How to send it by telegram bot?
c#
.Net Framework
Telegram.bot

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
judywb, 2020-01-02
@judywb

I found a solution:

using (var stream = System.IO.File.OpenRead(Путь до файла))
                {
                    InputOnlineFile iof = new InputOnlineFile(stream); //оставляем также 
                    iof.FileName = "Название файла(любое)"; 
                    var send = await bot.SendDocumentAsync(chatId, iof, "Текст сообщения под файлом");
                }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question