我想发送一个文件,该文件托管在私有服务器中(我的意思是没有公共URL)。 我认为我必须在Telegram.Bot库中使用SendDocumentAsync()。 问题是我不知道在发送文件之前是否已上传文件。 我已经尝试了下一个代码,但是没有用。
using (FileStream fs = System.IO.File.OpenRead("c:\test.txt"))
{
Telegram.Bot.Types.InputFiles.InputOnlineFile inputOnlineFile = new Telegram.Bot.
Types.InputFiles.InputOnlineFile(fs, "FileName.txt");
Bot.SendDocumentAsync(
chatId: new Telegram.Bot.Types.ChatId(12345),
document: inputOnlineFile,
caption: "User manual",
parseMode: ParseMode.Markdown);
}