[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

File Location on Deployment

I have a VB.net Windows application - Using VS 2003

I have a grid that loads it's layout from a text file. Currently in the code I have the location of the file coded to my local machine. But I want to deploy the application and need to know how I should go about implementing my code so the file can be found in its location after the project is deployed and executed. Should I store the file in the Bin folder? Here is my current code:

grdInventory.LoadLayout("C:\Desktop\Layout\grdInventory.txt")

Any help?
0
Gary2397
Asked:
Gary2397
  • 3
  • 3
1 Solution
 
Bob LearnedCommented:
Put it where the EXE is run from--Application.StartupPath

Bob
0
 
Gary2397Author Commented:
I have little experience with packaging a deploying. Will the application.startupPath be defined when creating the deployment package. Obviously, I need to modify the code before I package, how will I know what to put in the code? Thanks for your help.
0
 
Bob LearnedCommented:
1) Application.StartupPath is a run-time property, and not a deployment property.

2) It gets set when you execute the application.

3) Change the code like this:
   grdInventory.LoadLayout(IO.Path.Combine(Application.StartupPath, "grdInventory.txt")

Bob
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Gary2397Author Commented:
The code does work when I put the files in the bin folder. Now, will these files be created automatically in the bin folder when I package the application?
0
 
Bob LearnedCommented:
On the development machine, the application is built in the \bin folder, but on the production machine it won't be the \bin folder, but the target folder that you specified.

Bob
0
 
Gary2397Author Commented:
Wow, I am so sorry for not completely understanding this. If I keep all of the text files in a folder named "Layout", will I have to include the folder in the Install package. Would the code look like this:

grdInventory.LoadLayout(IO.Path.Combine(Application.StartupPath, "Layout\grdInventory.txt"))


How would the I get this "Layout" folder onto the machine the app was installed on? Thanks for being patient and explaining.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now