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

  • Home
  • SEARCH
  • 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 6346481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:01:31+00:00 2026-05-24T21:01:31+00:00

Goal: – Save a picture from my computer’s harddrive to the WPF’s application. –

  • 0

Goal:
– Save a picture from my computer’s harddrive to the WPF’s application.
– After adding a picture, you are enable to view the picture in visual Studio after updating the solution and projects.

Problem:

I don’t know HOW to save a picture inside of my WPF’s application. To
be more specificed I want the picture to be saved in the map
ArticlePicture from project DataAccessLibrary.

Again, I know how to do it in ASP.net MVC but not in WPF application. The syntax from MVC doesn’t work in WPF application.

Please remember that the picture is not directly from the Internet. I upload the picture directly from my personal computer to the WPF application. The WPF application is stored in my personal PC.

The input data of the picture take place in the project MediaStore

The directory address of the picture is:
“C:\Users\Fullmetalboy\Desktop\Firefox download\picture.gif”

Directory address of the project and its map ArticlePicture is:
“E:\Project\MediaStore\DataAccessLibrary\ArticlePicture\”

The goal is to add and copy the picture to the map “ArticlePicture” with this new address
“E:\Project\MediaStore\DataAccessLibrary\ArticlePicture\picture.gif

I have tried these links but unfortunately, it didn’t provide me any success.

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx
http://msdn.microsoft.com/en-us/library/ms748873.aspx#_imageformats

enter image description here

Syntax code in WPF application

private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

    dlg.Filter = "jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|jpeg files (*.jpeg)|*.jpeg";

    dlg.Multiselect = false;
    bool? result = dlg.ShowDialog();

    if (result == true)
    {
        Stream fInfo = dlg.OpenFile();



        using (System.Drawing.Image correctPicture = System.Drawing.Image.FromStream(fInfo))
        {

            if (correctPicture.Width <= 180 && correctPicture.Height <= 250)
            {
                var fileName = System.IO.Path.GetFileName(dlg.FileName);

                var path = System.IO.Path.Combine(Server.MapPath("/Content/Images/"), fileName);

            }
            else
            {

            }                    




        }


    }


}

Syntax code in ASP.net mVC //

// POST: /Admin/Produkt_ListaCreate/

[HttpPost, Authorize(Roles = "Admin")]
public ActionResult Produkt_ListaCreate(Bok pMyBok, HttpPostedFileBase file)
{

    if (file != null)
    {

        using (System.Drawing.Image correctPicture = System.Drawing.Image.FromStream(file.InputStream))
        {
            if (correctPicture.Width <= 180 && correctPicture.Height <= 250)
            {
                var fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("/Content/Images/"), fileName);
                file.SaveAs(path);
                pMyBok.BokBildUrl = "/Content/Images/" + fileName;
            }
            else
            {
                TempData["message"] = "Den uppladdade bilden fungerar inte pga att den uppfyller inte storlekens och formatets kriterier.";

                return RedirectToAction("index");
            }
        }   


    } // if (file != null)

    _myIBookRepository.Add(pMyBok);
    _myIBookRepository.Spara();
    TempData["message"] = "En boken är skapad.";

    return View("index");
}
  • 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-24T21:01:31+00:00Added an answer on May 24, 2026 at 9:01 pm

    Server.MapPath is not going to work in a WPF application – its for IIS applications.

    Where does this WPF application run? If its running from the same machine, what directory is it being run from? You need some way for the WPF application to determine where the ArticlePicture directory resides.

    Assuming you are running the WPF application from the web server, you know where the directory resides, and the WPF application has permissions to access the directory, then all you need to do is to a file copy operation. (I see no reason to save the file back out of the WPF application if it is not modified).

    I suspect maybe your intention is to upload the picture to the website via the WPF application. If so you might need to explain more clearly.

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

Sidebar

Related Questions

Goal: To use entity framework with N-tier in my WPF application. Problem: I can't
Goal of the application is get latest post from facebook, it is possible if
Goal: Having two buttons that should be enable to add or delete data from
Goal: Enable closing of the application's window(s) independently without affecting others. The application is
My goal is to maintain a web file server separately from my main ASP.NET
The goal: To create a .NET dll i can reference from inside SQL Server
Goal: Retrieve all instance of List<> from interface GameFactory Problem: I retrieve error message
Goal: Provide a web service using Visual Basic or C# or .NET that interacts
Goal: Parse a string from an input type text into TIME type to be
Goal: Get the TEXT address and then display the street view and map view

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.