Problems finding config files in Excel application

Joined
Jun 2, 2011
Messages
16
Programming Experience
3-5
I am using VS2010 to develop a simple application for work. The project consists of two parts.

1. A Class (.dll) project that has general, utility stuff for the API that I am working with. This project relies on a text file for some lookup information. I use this project in other solution, and it works fine.

2. An Excel project that relies on the the .dll project above.

The Problem: when I use functions in the Excel project from the Utility Class which rely on the .txt Lookup file, I get an error: 'cannot find file c:/user/me/documents/lookup.txt.' The project does not exist in this directory, and references it in no way that I can see. If I take 'lookup.txt' and put a copy in that directory, the application runs fine.

I had these projects on a different computer, and I had the same problem, though the documents path was different. What it common is that my little project is looking in the default 'documents' directory on both systems.

Any help would be appreciated.
 
Most likely you are just referring to the file by name and not using a path. When you do that, it will assume the current application's working directory, wherever that may be, which can change while the app is running. If you want a specific folder then you must specify that folder.
 
Most likely you are just referring to the file by name and not using a path. When you do that, it will assume the current application's working directory, wherever that may be, which can change while the app is running. If you want a specific folder then you must specify that folder.

Thank you.

Is there a smart way to manage my default path when I deploy this thing? Do I just save the root directory as an application variable? How would a real vb.net developer do it?
 
Where is this file supposed to be in relation to your library? Are they both going to be in the same folder as the EXE that references the library? If so then you should use Application.StartupPath to get the folder path. If it's something else then you'll need to use something else appropriate.
 
Back
Top