Solved

c# locate resource file

Posted on 2011-03-01
4
375 Views
Last Modified: 2013-12-17
Hi,
I develop my app on eg. f:\myapp\ where I save my resource file in the app.conf where
I indicate my resource file location as f:\myapp\resources\res.bin.
When I copy my program to other computer and run on c:\ drive. The program coult not start because it is looling for f:\ drive. How can I solve this issue?

Thanks,
JT
0
Comment
Question by:jtran007
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:crysallus
crysallus earned 200 total points
ID: 35014788
To specify the file resources\res.bin relative to the location of the executable, use:

Application.StartupPath + Path.DirectorySeparatorChar + "resources" + Path.DirectorySeparatorChar + "res.bin"

Open in new window

0
 
LVL 7

Accepted Solution

by:
mkobrin earned 300 total points
ID: 35014794
Go to the properties of your resource file in you Visual Studio IDE and set the option to copy the resource locally and then recompile the code. The resource file will then be local, and you will not have to another drive to find it.
0
 

Author Comment

by:jtran007
ID: 35023702
HI,

But what is the syntax to open this file? ".\resources\res.bin"

Thanks,
JT
0
 

Author Closing Comment

by:jtran007
ID: 35380741
Thanks,
JT
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now