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 6809581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:06:12+00:00 2026-05-26T20:06:12+00:00

I have a problem with a string value. The string is globally declared. The

  • 0

I have a problem with a string value. The string is globally declared. The string is name_file_image.

I have this code:

            // iterate image files
            foreach (XElement node in xml.Element("graphics").Elements("file"))
            {
                // pick image 
                if (node.Attribute("type").Value == "image")
                {

                    // demoing that we found something                
                    //MessageBox.Show(node.Element("fileurl").Value);
                    string url_image = node.Element("fileurl").Value;
                    string[] array = url_image.Split('/');
                    **name_file_image** = array[array.Length - 1];
                    //MessageBox.Show(**name_file_image**);
                    WebClient webClient = new WebClient();
                    webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_image);
                    webClient.OpenReadAsync(new Uri(url_image));
                }
            } 

    void webClient_image(object sender, OpenReadCompletedEventArgs e)
    {
        try
        {
            if (e.Result != null)
            {
                // Save image to Isolated Storage


                // Create virtual store and file stream. Check for duplicate JPEG files.
                using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (myIsolatedStorage.FileExists(**name_file_image**))
                    {
                        myIsolatedStorage.DeleteFile(**name_file_image**);
                    }

                    IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(name_file_image, FileMode.Create, myIsolatedStorage);


                    BitmapImage bitmap = new BitmapImage();
                    bitmap.SetSource(e.Result);

                    WriteableBitmap wb = new WriteableBitmap(bitmap);
                    wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
                    fileStream.Close();

                    //MessageBox.Show(name_file_image);
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    } 

I read the XML from a file in memory and I want to save the images with the name present in the XML. But I have a problem. The variable string always has the same name. I suppose the code is not correct. Any help?

  • 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-05-26T20:06:13+00:00Added an answer on May 26, 2026 at 8:06 pm

    You’re calling the WebClient.OpenReadAsync method, which is doing his work (as the name suggests) asynchronous. To fix this issue, you have to pass the filename with the OpenReadAsync() method.

    In your case that will be:
    webClient.OpenReadAsync(new Uri(url_image), name_file_image);

    In your webClient_image eventhandler you can than extract the value from the OpenReadCompletedEventArgs parameter. The parameter e has a few properties. e.UserState should now contain your filename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem while converting a string whose value is dd.mm.yyyy to DateTime
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
Hi all I have problem with following: foreach (DataRow dr in data.Tables[0].Rows) { string
I have a Dictionary with some simple string,string value pairs. The problem is that
Hi I have a problem with this code: unit Unit1; interface uses Windows, Messages,
I am using LaTeX and I have a problem concerning string manipulation. I want
I have a problem with a string in C++ which has several words in
I have a problem that output string must be utf8-formatted, I am writing currently
I have a problem converting a string binary to a decimal I was using
I have a performance problem related to string comparison (in Java). I'm working on

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.