473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

help using relative file paths with loadfile

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);
Feb 21 '07 #1
1 3996
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.

"Peted" wrote:
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);
Feb 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Doug | last post by:
If I were to write an include with a relative path like include("../conf/config.php"); What is the use? As far as I understand it, the path is relative to the first script that is called by...
5
by: DaveB | last post by:
I have to come up to speed quickly on PHP since I have been given the responsibilty of updating our website. I have setup a local web server through IIS, downloaded and installed PHP. I'm using...
3
by: epigram | last post by:
I've got a javascript menu that uses an external .js file. In the .js file, there is a function that gets called by each of my .html pages to build up the menu for the page. The way I want to...
2
by: Joe | last post by:
Hi, can someone tell me how to set up relativ paths in VS2003 C++ ? I have some source with a tree directory structure that segments include files in various directories: #include...
11
by: MBS | last post by:
I am playing around with some PHP code. I want to put in an include() function so I can include existing HTML code and output it to the browser. Lo and behold PHP does not support relative paths...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
19
by: Jerry M. Gartner | last post by:
Greetings: What is the best way to resolve paths within a document regardless of what path it is opened under? For example: I have x.php and it contains <img src="images...">, (amongst other...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
3
by: CaseT | last post by:
Hi, My company's website is down so I'm hoping someone has seen this bizarre problem/behavior before and can help me out .. We have a USA and an International site. Two directories under the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.