© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
117 replies
BigggMoustache

GetStreamAsync() Stream Always Null [Answered]

I'm getting a URI from json on my computer and trying to download an image from it.
Everything works up to actually putting something in
requestBodyStream
requestBodyStream
. It is forever null.
        public static async Task DownloadFunction(List<Card> cards)
        {
            foreach(Card card in cards)
{
                var requestBodyStream = await client.GetStreamAsync(card.ImageUris.Small);
                var fileStream = File.Create($@"C:\Users\samue\Desktop\MTGImage\{card.Name}.jpg");

                await requestBodyStream.CopyToAsync(fileStream);
                await fileStream.FlushAsync();
            }
        }
        public static async Task DownloadFunction(List<Card> cards)
        {
            foreach(Card card in cards)
{
                var requestBodyStream = await client.GetStreamAsync(card.ImageUris.Small);
                var fileStream = File.Create($@"C:\Users\samue\Desktop\MTGImage\{card.Name}.jpg");

                await requestBodyStream.CopyToAsync(fileStream);
                await fileStream.FlushAsync();
            }
        }

The next debug
Step Into
Step Into
would be to get the URI, which it shows by going to the model. Then it seems like it skips the next three lines of code and goes to the second object in the foreach loop. Pressing
Step Into
Step Into
again on the last item in the list of
cards
cards
finishes the program. Nothing is ever downloaded.
unknown.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

WPF MVVM PropertyChangedEventHandler always null - Not updating Binding [Answered]
C#CC# / help
4y ago
❔ Callback Url Always Null
C#CC# / help
4y ago
WinUI3 - Button always disabled [Answered]
C#CC# / help
4y ago
Id points to always null
C#CC# / help
12mo ago