Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:37:01+00:00 2026-06-05T01:37:01+00:00

In WinRT / C#, How do I download an image to a local folder

  • 0

In WinRT / C#, How do I download an image to a local folder to support caching of an online catalogue for offline use? is there a way to directly download the images and link the control to get them from the cache as a fallback?

    var downloadedimage = await HttpWebRequest.Create(url).GetResponseAsync();
    StorageFile imgfile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
                        "localfile.png", CreationCollisionOption.FailIfExists);

What do I do next to store downloadedimage as localfile.jpg?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:37:02+00:00Added an answer on June 5, 2026 at 1:37 am

    Looks like the code below from the HttpClient sample for Windows 8 solves the issue

        HttpRequestMessage request = new HttpRequestMessage(
            HttpMethod.Get, resourceAddress);
        HttpResponseMessage response = await rootPage.httpClient.SendAsync(request,
            HttpCompletionOption.ResponseHeadersRead);
    

    httpClient is a HttpClient, and its BaseAddress needs to be set a the server folder of your resource. we can then do this to convert that to an image source (if that’s what we’re downloading)

        InMemoryRandomAccessStream randomAccessStream = 
            new InMemoryRandomAccessStream();
        DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0));
        writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());
        await writer.StoreAsync();
        BitmapImage image = new BitmapImage();
        imagecontrol.SetSource(randomAccessStream);
    

    or this to write it to file

        var imageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
             filename, CreationCollisionOption.ReplaceExisting);
        var fs = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
        DataWriter writer = new DataWriter(fs.GetOutputStreamAt(0));
        writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());
        await writer.StoreAsync();
        writer.DetachStream();
        await fs.FlushAsync();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to write WinRT apps in Windows7 & VS2010? Some SDK
Possible Duplicate: Is there a way to write WinRT apps in Windows7 & VS2010?
Is there a sample code available online to get WinRT to determine if its
I am writing a C++ WinRT Component DLL for use in my .NET-based WinRT
I am wondering if there is any (Win8 Metro-styled) WinRT/XAML component that can be
How is WinRT implemented beneath the hood? Uses NT directly kernel directly or is
I'm trying to create a C# WinRT component for use in metro style applications
Can we use NuGet packages in developing WinRT Metro style applications using XAML/C# or
Is there an equivalent to HttpUtility.HtmlDecode in WinRT? I'm developing a MetroStyle app and
Is there a good way to get the process name that created a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.