Telegram Bot API does not send the file?

Happy new year! (for all reading in 2020 to come) )

Can't deal with the bot trying to send a file from your PC.
In fact, the essence of the bot: at home, on your home wifi network is Rasbery PI as a server that revolves in the cycle of the server part with the bot - the bot accepts the url you want to save a web page locally on external usb connected to the raspberry. But, I also want to have access to saved files not only in your home network and do a static ip on the raspberry (it also is worth apache and COPS (OPDS catalog)) - do not want, therefore, organized a "fellowship" all using the same bot:
In fact, "communication" with the bot (I know that you can make a keyboard with buttons, but it's more of a training project for yourself and then I was even more interesting to do the bike)
if (e.Message.Text.StartsWith("$"))//command
{
 switch (e.Message.Text)
{
 case "$help":
 bot.SendTextMessageAsync(new Telegram.Bot.Types.ChatId(id), "send me some commands:\n $help-to see commands list\n" +
 "$books_log - to see list of saved books (from log file)\n $books_list - to see list of saved books(get files name from storage)\n $download - to download some article");
break;
 case "$books_log":
 bot.SendTextMessageAsync(new Telegram.Bot.Types.ChatId(id) File.ReadAllText("URLLogs.txt"));
break;
 case "$books_list":
GetBooksList();
break;


default:
 if (e.Message.Text.StartsWith("$download"))
{
 string pathToFile = GetDownloadFilePath(e.Message.Text.Substring(e.Message.Text.IndexOf(" ") + 1), e);
try
{
 if (File.Exists(pathToFile))
{
 Console.WriteLine("file exist");
}
else
{
 Console.WriteLine("file NOT exist");
}



 using (var stream = File.OpenRead(pathToFile))
{
 InputOnlineFile iof = new InputOnlineFile(stream);
 iof.FileName = "";
 var send = bot.SendDocumentAsync(new Telegram.Bot.Types.ChatId(id), iof, Message);
}

 //bot.SendDocumentAsync(new Telegram.Bot.Types.ChatId(id), new Telegram.Bot.Types.InputFiles.InputOnlineFile(pathToFile));

}
 catch (Exception ex)
{

Console.WriteLine(ex);
}
}
break;
}

 return false;
 }

The problem: the code fulfills without errors, the console displays that the file exists, but the file (. htm page) - I don't get.
April 4th 20 at 00:27
1 answer
April 4th 20 at 00:29
Judging by the method name "SendTextMessageAsync", when it is called you need to use "await".

The same applies to a method call "SendDocumentAsync".

Find more questions by tags C#BotsTelegram