hi, how to set a proper path of a image file, many thanks!

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 1
Reputation: raybristol is an unknown quantity at this point 
Solved Threads: 0
raybristol raybristol is offline Offline
Newbie Poster

hi, how to set a proper path of a image file, many thanks!

 
0
  #1
Jun 26th, 2005
I can load a image file from a fold if I did like this:

Bitmap myBitmap3 = new Bitmap(@"C:\HEapp\images\logo.bmp");

however, this is not convenient if I move my program, so I was try to do this:

Bitmap myBitmap3 = new Bitmap(@"\images\logo.bmp");

however, it doesn't work, could anyone tell me how to do this, many thanks!!

another question, how do I export a porper exe file which can run on a computer has no framework installed?

many thanks!!!!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: hi, how to set a proper path of a image file, many thanks!

 
0
  #2
Jun 28th, 2005
It needs to be an absolute path to the file, so you need to use Server.MapPath()

like so...
Bitmap myBitmap3 = new Bitmap(Server.MapPath("~/images/logo.bmp"));

(Assuming this is a web app)

if this is not a web app, and you plan on moving this around, I suggest setting a key in the config file of the root path like <add key="root" value="C:\mystuff\" />
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1
Reputation: mainline is an unknown quantity at this point 
Solved Threads: 0
mainline mainline is offline Offline
Newbie Poster

Re: hi, how to set a proper path of a image file, many thanks!

 
0
  #3
Jul 1st, 2005
If your just looking to reference a file from the current directory, you can drop the first \. @"images\logo.bmp" might be what your looking for.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1
Reputation: BSTRhino is an unknown quantity at this point 
Solved Threads: 0
BSTRhino BSTRhino is offline Offline
Newbie Poster

Re: hi, how to set a proper path of a image file, many thanks!

 
0
  #4
Jul 4th, 2005
I'm not sure if this is the question that raybristol is asking, but I do wonder, how do you get a path to the place where the EXE is located, from which you can find the folder it is in and so on? What I mean is, how could you make it so you can place the EXE anywhere, whether it be C:\My Documents\HelloWorld.exe or C:\Program Files\Hello\HelloWorld.exe and the program would still be able to find out where you put it?
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 55
Reputation: r0ckbaer is an unknown quantity at this point 
Solved Threads: 6
r0ckbaer r0ckbaer is offline Offline
Junior Poster in Training

Re: hi, how to set a proper path of a image file, many thanks!

 
0
  #5
Jul 4th, 2005
Application.ExecutablePath <-- Path + executable name
Application.StartupPath <-- Only path
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC