?
Solved

Load external ressources in c#

Posted on 2009-04-20
3
Medium Priority
?
369 Views
Last Modified: 2012-05-06
For a program I need to load and assign dynamically an image.

I've something like this:

FileStream file;
file = File.Open(@"./Ressources/led_on.png", FileMode.Open);
ledON = Image.FromStream(file);

But it's search in the bin/Debug repository. Is it possible to search the ressource folder in the source folder?(or have an automatic copy?)
0
Comment
Question by:Nargzul
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
abel earned 2000 total points
ID: 24183932
Use an automatic copy. See the screenshot for where to do that (in the Properties window of the file). Then, on every build, whether it is release or debug, the file and its relative location in the directory structure will be copied to the build location.

ScreenShot221.png
0
 
LVL 1

Author Comment

by:Nargzul
ID: 24183962
It's on the Ressource tab?

Is it a way to include files corresponding to a pattern?

Like ressources/*.(png|jpg|gif) ?(or simply ressources/*
0
 
LVL 39

Expert Comment

by:abel
ID: 24185804
?

Sorry, I don't know what you mean. But what I mean is:

1. go to the Solution Explorer
2. Select the Resources/myfile.png file
3. Select the Properties window (right-click > Properties)
4. Change the "Copy to Output Directory" setting

that's all there is to it ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question