I am new in C#. I had create a project and i make it executable. I install it to another PC and it runs. I had a picturebox button and when you click on it, it will change the picture. In my PC works perfect because the directory with .gif exists, but in the other PC it can't find it and throws me exception "Exception HRESULT : {0x800700C1}" .
I load the new picture in picturebox button like below :
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Photos\preview2.gif");
pictureBox2.Image = Image.FromFile(path);
I make my application an executable file with Inno Setup Compiler and now i have only an application.exe which include the executable file of my project with the contents files.
When i run my application in another PC tell me that it don't find the .gif
You could add your images as resources into the project. Right-click your project and look for the "Resources" tab, then add the images to your project.
Another option is to just copy them to the other machine, into a location you can predict such as "My Pictures", and then load them using:
string path =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
"preview2.gif");
User contributions licensed under CC BY-SA 3.0