help using relative file paths with loadfile

P

Peted

Hello

bellow is select sample of code im using to dynamicaly load
assembley's and it works, but the assembley.loadfile requires that i
use a absolute directory path.

Is there anyway i can use a relative file path. I just want to access
the dll in subdirectory "deviceinterface" to where the application is
located. (regardeless where the app is located)

any help appreciated

thanks

Peted




DirectoryInfo devDir;
FileInfo[] iplDevFiles;

/* list all device interfaces in the directory for user access */
devDir = new DirectoryInfo(@"C:\Documents and
Settings\spock\My Documents\Visual Studio
2005\Projects\IPLinkerator\IPLinkerator\bin\Debug\DeviceInterface\");
iplDevFiles = devDir.GetFiles("*.dll");




// Dynamically load the selected assembly.
deviceInterfaceAssembly = Assembly.LoadFile(devDir +
devicefile);
 
G

Guest

Server.MapPath(..) will do it for ASP.NET.

For anything else you could always store a root as an Application
Configuration key. Then concat that to any relative path you use throughout
your app.

I recommend 70-536 study guide for figuring the code for that. MSDN
documentation is as good if your willing to dig.
 

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