Results 1 to 4 of 4

Thread: [RESOLVED] How to access a file after click once deploys it

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a new Maserati down a dead end street
    Posts
    4,267

    Resolved [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.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a new Maserati down a dead end street
    Posts
    4,267

    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.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,532

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a new Maserati down a dead end street
    Posts
    4,267

    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!
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width