1

I have folder inside my project called "Multimedia". I want to use C# code to update this folder with images that my users selected. Now i have tried this:

     string path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.Length - 10);
            string name = Path.GetFileName(MyDialog.FileName);
            File.Copy(MyDialog.FileName, path + "\\Multimedia\\" + name);
            LogoMovie.Source = new BitmapImage(new Uri(@"/QuillaCine;component/Multimedia/" + name, UriKind.RelativeOrAbsolute));

And this copies the image into the folder, but in the Solution Explorer, the folder remains empty. I need that the images appear in the Solution Explorer with Built-In acction set to "Resources".

Any help would be great

Eternalknight
  • 25
  • 2
  • 7

2 Answers2

2

New files are not added to the Solution Explorer. Click the SHOW HIDDEN FILES button in the Solution Explorer toolbar, and then you will see these new files. You will then need to include them in the project (right-click > include files), and then set them as Resource in the properties.

To automate all of this, you would need to create a VSIX Package/extension for Visual Studio, or automatically edit the .csproj file. Can get messy.

Dax Pandhi
  • 843
  • 4
  • 13
  • 1
    just for curiosity, how exactly would you automatically edit the .csproj file? – Eternalknight Oct 09 '15 at 05:00
  • You can load it as an XML file and add the following chunk of code to the main node. ` ` – Dax Pandhi Oct 09 '15 at 05:10
  • Do note that this is only for the sake of development, when END-USERS select their own images, simply copy them to Application directory, and OnStartup, load them into some `ResourceDictionary` – fahimalizain Oct 09 '15 at 07:58
2

1. Adding resources with the drag and drop

You can simply open two windows. One containing your visual studio instance and the other the parent of the folder you want to get the file from. Make sure to be in the solution view in your VS.

enter image description here

enter image description here

Simply drag and drop from folder to VS. That is as simple as it gets. or you can follow Gants answer.

N Djel Okoye
  • 950
  • 12
  • 10