[RESOLVED] How to access a file after click once deploys it
Hi. I have a click-once WinForms application that I've been deploying for years. Recently I enhanced my code to get a custom color out of a bmp file. That is, I have several labels on a form that I want to set to the same shade of blue as our company logo. To do that I've coded the following:
Code:
Image imageNorcomBlue = Image.FromFile(@"..\..\..\Images\NorcomBlue.bmp");
Color NorcomBlue = ((Bitmap)imageNorcomBlue).GetPixel(1, 1);
lbStatusBanner.BackColor = NorcomBlue;
When I deployed and ran the app, I got an IO exception because the file wasn't found.
I am not sure how to get it out there for everyone.
I've found advice such as the following: You can add a file to the deployment by adding the file to your project in VS. Once you do that, you can click on the file in the solution explorer and then change the build action to content. So the file is in my solution already. I have a folder called Images and NorcomBlue.bmp is inside the folder. But when I click the file and look at its properties, there is no Build Action. Only name, date created, dated modified, file path (which is local to my computer), file size and read-only = false (I perhaps want to change that to true). Anyway, since I am not using this strictly as an image but as a file to get some info from, it doesn't really follow the normal procedures of deploying images. Any idea how I can deploy and access it? Thank you.
Re: How to access a file after click once deploys it
I am going to try this: imageNorcomBlue = Image.FromFile(@"Resources\NorcomBlue.bmp"); I just have to make sure no one updates the application while I'm testing it deployed. Will keep you posted. Thanks.
Re: How to access a file after click once deploys it
Did you add it as a file or as a resource? If you added it as a resource, that's why you don't see the build options in the properties window. If you add it as a file, not a resource, then you should see the additional properties. I think. I think I have that right. I don't have VS handy to double check.
-tg
Re: How to access a file after click once deploys it
Yes, thank you tg. It took a couple tries (but it's 6:49 pm so I have the liberty of screwing up all I want) but I finally got it. What I had said at 1:58 PM wasn't the whole story. I put the file in the Resources folder and set its Build Action = Content and Copy to Output Directory = Copy always. All set!