Windows Develop Bookmark and Share   
 index > Windows Forms General > Application Directory
 

Application Directory

I have some files i need to access from the application i am building and i would like to be able to put these files in the same directory as the application, BUT i need the variable that  will allow me to reference this location. 

For instance i cant say that it is located in "C:\AppName\files"
i need it to say it is located in ApplicationDirectory+"\files"
so that this program can be installed anywhere and as long as the files i need are in the same director as the application everything will be cool.

So in conclusion,
What is the variable to know the current directory of the application?
MigrationUser 1  Friday, April 08, 2005 10:09 AM
i have found the command Application.StartupPath but when i type it in it says 
"Reference to a non shared member requires an object reference"

What reference do i need to add to make this command work?
MigrationUser 1  Friday, April 08, 2005 10:20 AM
i added this 


Dim a As Application
        Me.lblError1.Text = a.StartupPath

but the output directory has nothing to do with my application the path it gives is 
"C:\Documents and Settings\Blackdisk\Application Data\Microsoft\Word\STARTUP"

This directory is empty and nothing is used from here, i really dont even know why it is giving this directory, unless this is the incorrect command for this purpose

the correct directory should be (Currrently)

"C:\Documents and Settings\Blackdisk\My Documents\Visual Studio Projects\SnailMailMerge\bin"
MigrationUser 1  Friday, April 08, 2005 10:29 AM
alright i figured it out, it was conflicting with 


'Imports Microsoft.Office.Interop.Word
'Imports Microsoft.Office.Interop
</Code>

these also have the Application class, but it relates to word and not the actual application 
MigrationUser 1  Friday, April 08, 2005 10:44 AM

You can use google to search for other answers

Custom Search

More Threads

• question about class attributes
• [Help] Web Browser
• Trackbar Background Colour in Windows Vista
• Funny problem using Graphics::DrawString(...)
• Windows form controls Using in webforms
• Access Controls or Variables on other forms
• RE: BindingNavigator
• Form navigation component?
• Switch connectionstring for TableAdapter
• missing storage-class or type specifiers error