?
Solved

File Location Code

Posted on 2006-10-25
3
Medium Priority
?
173 Views
Last Modified: 2010-04-16
Hi,
What code would I use if I wanted a picturebox to be populated with image that by default should be in the following path:

C:\Program Files\Application X\Images

But lets say the user installs the program to

C:\Program Files\Application B\Images

I guess what I am trying to ask is what code can i use so that no matter where the user installe the program the image file is always being pulled one level below the root application?

I have been play around with the following code and I am stilll having issues with it.

ResultantImage.Image = Image.FromFile(@"..\\..\\SnowFlake001.bmp");

Thanks

Peter
0
Comment
Question by:schenkp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Expert1701 earned 2000 total points
ID: 17808370
Try,

  ResultantImage.Image = Image.FromFile(@"Images\SnowFlake001.bmp");

or,

  ResultantImage.Image = Image.FromFile(@".\Images\SnowFlake001.bmp");

or, to ignore the "working directory" and locate a file relative to the executing application:

  System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase), @"Images\SnowFlake001.bmp")
0
 
LVL 21

Expert Comment

by:K V
ID: 17809966
app.path will give u current exe path
do whatever thereafter
0
 
LVL 21

Expert Comment

by:K V
ID: 17809975
sorry its this:

AppDomain.CurrentDomain.BaseDirectory
or
Application.StartupPath()
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

719 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