Loading files from a Class Library

N

Nathan

Just starting .Net and already run into problems.

Within a Dll in VB6 I could access App.Path and load files directly from the
dll e.g. ini file, now in a .Net Windows application I can use
Application.StartupPath but in a ClassLibrary application isn't available,
so what can I use to get the dll's directory where the files to be loaded
will be stored?

As an aside the files I want to load are XML & XSL and need to be external
to the dll so that they can be maniputlated without having to re-build the
Class Library.

Nathan
 
H

Herfried K. Wagner [MVP]

* "Nathan said:
Within a Dll in VB6 I could access App.Path and load files directly from the
dll e.g. ini file, now in a .Net Windows application I can use
Application.StartupPath but in a ClassLibrary application isn't available,
so what can I use to get the dll's directory where the files to be loaded
will be stored?

\\\
Imports System.IO
Imports System.Reflection
..
..
..
Private Function ApplicationPath() As String
Return _
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function
///
 
N

Nathan

I've solved my problem by using
System.Reflection.Assembly.GetExecutingAssembly.Location to give me the
location of my class library and then use this to enable me to load any
files that I may require to allow me to configure the Class Library,
manipulate XML etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top