Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Adding an image folder to Visual Studio 2005

  • 04-08-2006 12:22pm
    #1
    Closed Accounts Posts: 181 ✭✭


    Hi,

    I have developed a small c# win form that when a user clicks a button it puts an certain image into a picturebox, with the following code

    picturebox1.Image = "C:\\Image\\ " + image +".jpg";

    and it works fine, but when I publish the c# form and copy it to disk and set it up on another pc, it retrns an error saying that the path is incorrect, I know the problem is, is that the cd cannot access the c drive and view the images, so I changed the file location to the project folder, below is the code

    picturebox1.Image = "C:\\ProgFolder\\ImageFolder\\ " + image + ".jpg";

    and I hoped that when I recompiled it would store a local copy on the disk, but it did not, Now I have two options,

    1. Storing the images in an access database and calling them from there and from what I have read it this is bad pratice,

    2. I am not sure if this can be done but I was hoping to add the image folder to the app data folder and call the images locally. Does any one know if this can be done,Any links or help would be great.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Can you post the full error message? It will tell us exactly why it can't see the folder.


  • Closed Accounts Posts: 181 ✭✭deadfingers


    Hi,

    The error that comes up is just the path name that I had the files in,

    C:\Images\image.jpg.

    What I want to be able to do is bundle the file with the images with the program like you would do with a database.

    I have created a folder in solution explorer called Images and have stored all my images in that folder and when I go to build the program using setup and deployment I cannot add the images folder although I can add the images seperately, but I have over 2000 images.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Sorry I'm not paying attention. Your code couldn't be even compiling for you. You need to use:
    pictureBox1.[COLOR="Red"]ImageLocation[/COLOR] = "C:\\images\\image.jpg";
    


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Presumably the error is down to the fact that the images aren't being deployed along with the application ?

    There's a couple of options you have. One is to use a deployment/setup/installer (I can't remember which it's called) project to deploy your application instead of the publish option. In the 'File System' section of this you can add a subfolder of your application folder and put the images into that. They'll then be built into the setup.exe and you can access them in your program using the startup path of your application i.e. somthine like
    pictureBox1.ImageLocation = Application.StartupPath + "Images\Picture1.jpg"
    

    You could also try adding a subfolder directly to your project in the solution explorer, use the 'add existing items' option to add the images in and in the properties of each image file change the 'Copy To Output' option to 'Always' or 'If Newer'. That might work with the publish option.


  • Closed Accounts Posts: 181 ✭✭deadfingers


    Well I am not really paying attention either ,no I left out that bit out by mistake in my post but not in my code, my program runs perfect on my machine but when I deploy it to another machine thats when the error occuors, because I cannot seem to be able to attach the images to my project when I deploy it. I am starting to think now that I may have to write some form of a script that during installation it will copy over the image folder to the default installion location and just call the images from there.


  • Advertisement
  • Closed Accounts Posts: 181 ✭✭deadfingers


    Hi stevenmu,

    Thats exactly what I was looking to do, I wont get a chance to do it till Tuesday morning, but thats great, thanks a million


  • Registered Users, Registered Users 2 Posts: 640 ✭✭✭Kernel32


    Put the image(s) in a resource file and read it out from there.


Advertisement