Working within project directory

jamie_pattison

Well-known member
Joined
Sep 9, 2008
Messages
116
Programming Experience
Beginner
I have Visual Studio 2008 installed. I create a project and within this project i create a directory called "images".

1. I would like to work with this directory in code by specifying the path. Currently the only way to do this is by pointing to "C:\Documents and Settings\jamie_pattison\My Documents\Visual Studio 2008\Projects\Service\Images"

The name of my project is Services and within services is the images folder. So how could i reference this folder without using the full path as above?

2. This folder when deploying needs to be copied to the program files directory. Would this be added as part of the setup installation?

Thank you
 
What I would do is include the Images folder only, have it deployed to the same folder as the app's exe and dll's this way in code you can get to it using the
VB.NET:
Application.StartupPath & IO.Path.DirectorySeparatorChar & "Images" & IO.Path.DirectorySeparatorChar
 
What I would do is include the Images folder only, have it deployed to the same folder as the app's exe and dll's this way in code you can get to it using the
VB.NET:
Application.StartupPath & IO.Path.DirectorySeparatorChar & "Images" & IO.Path.DirectorySeparatorChar

What if your testing this at run time and this folder is not available in program files directory? how could i test it then?
 
There's two kinds of "testing" and both of them are at run time, there's the IDE testing where you test stuff as you're developing and then there's deployment testing, meaning you're testing things out including your installer. Since the installer would take care of making sure it exists where it needs to be that leaves us with testing things from the IDE, if the folder structure is set up in your project folder the same as it would when it's deployed then it's already set up as it needs to be.

If the deployment folder structure is intended to be:
Program Files\YourApp\MainExe.exe
Program Files\YourApp\Images\Image1.jpg
Program Files\YourApp\Images\Image2.jpg

Then your IDE project would be:
\bin\debug\MainExe.exe
\bin\debug\Images\Image1.jpg
\bin\debug\Images\Image2.jpg

And code like:
VB.NET:
Application.StartupPath & IO.Path.DirectorySeparatorChar & "Images" & IO.Path.DirectorySeparatorChar
Works the same whether it's deployed or not.

Also keep in mind that this is simply 1 suggestion, there are other ways to go about this.
 
Back
Top