I would like to use a stream of the same image in a foreach statement. The problem is that after the first item is processed in the foreach statement the stream in the "images" dictionary is emptied (length = 0).
Are my only options are to copy the stream to a file or database? I would like to avoid that if it's possible.
Here is my code:
public int SendImage(string TweetText, List<long> TweetIDs, Dictionary<string, Stream> images)
{
TwitterService service = twitterAPI.Twitterservice();
GetTweetOptions tweetOptions = new GetTweetOptions();
//It works fine on the first tweetid but after that the Stream's length = 0
foreach (long _tweetid in TweetIDs)
{
tweetOptions.Id = _tweetid;
TwitterUser twitteruser = service.GetTweet(tweetOptions).User;
service.SendTweetWithMedia(new SendTweetWithMediaOptions { Status = "@" + twitteruser.ScreenName + " " + TweetText, InReplyToStatusId = _tweetid, Images = images });
}
}
Thank you!
Thanks to [John_ReinstateMonica][1] for helping me solve the problem.
Rather than passing the image stream I'm passing the byte object of that stream then included it in the foreach block then converted it to a stream for every iteration.
Now the image is being sent for each tweet!