Modify file in resources directory in Visual Studio

1

Hi, I'm doing a project in visual studio 2015 and I have a PictureBox whose image is taken from the Resources folder. That image I will need to change every day I'm trying to change the image by hand replacing it in the directory, but then when executing the application it shows the old one.

Does anyone know if it is possible what I am trying? Thanks

    
asked by Sergio Carvajal Alonso 23.11.2016 в 19:58
source

3 answers

1

No. if you saved it as an embedded resource in the application, no. You should upload it directly from the necessary folder to be able to do what you want.

    
answered by 23.11.2016 / 19:59
source
2

In the end I solve it by reading the file from a route (which, as in my application, does not change, this solution helps me) with File.Readallbytes

byte[] ImageByte =  File.ReadAllBytes(Application.StartupPath + "/bote.jpg");
MemoryStream MemStream = new MemoryStream(ImageByte);
pictureBox1.Image = Image.FromStream(MemStream);
    
answered by 09.12.2016 в 19:48
1

You tried to load the image from a file in the following way:

    string ImagesDirectory = 
        Path.Combine(
            Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
            "imagenes"
        );
   string rutaImagen = Path.Combine(ImagesDirectory, "nombreArchivo.png");
   pictureBox1.image = =Image.FromFile(rutaImagen);
    
answered by 24.11.2016 в 04:03