Solved

File Location Code

Posted on 2006-10-25
3
171 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

626 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