Skip to content
Alex edited this page Jun 25, 2017 · 3 revisions

Sending a new photo

If you want to upload a new photo and it does not exist on Telegram servers, you can use the NewFile class. Don't forget to set FileName property. If you don't, the photo will not be sent.

var client = new TelegramBotClient()
{
    Token = "",
};

var photo = new NewFile()
{
    FileContent = System.IO.File.ReadAllBytes("PATH TO YOUR PHOTO"),
    FileName = "FILENAME.EXT"
};

client.SendPhoto(chatId, photo);

Sending an existing photo on Telegram servers

Each file on Telegram servers has an identity string (named: file_id). You can use the ExistingFile class to send photos already on Telegram servers.

var client = new TelegramBotClient()
{
    Token = "",
};

var photo = new ExistingFile()
{
    FileId = "YOUR FILE ID"
};

client.SendPhoto(chatId, photo);