473,473 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Startup path

JJ
Hi,

Using the app.config scenario and I added a Connectionstring to appSettings
area in xml. In the value string I have the datasource equal to a absolute
path on my dev machine. Now how can I set it to be relative to where my
project gets deployed to? Do I use Application.Startup in the connection
string startup as so :

<appSettings>
<add key="myCon" value="{"Jet OLEDB:Database Password=;Data Source=" +
Application.Startup + "EMSWinDB.mdb';Password=;"};
</add>
</appSettings>

Or is there a better way, more effiecent way of doing this?

Thanks,

JJ
Nov 15 '05 #1
5 7128
Hi JJ,

If you want to dinamically change it you will have to do so in code, what
you can do is split the Connectionstring in two parts and later in the code
concatenate it with the dinamic value:
something like this:

connection.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings["myCon"] +
Application.Startup .....

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"JJ" <jm***@bellatlantic.net> wrote in message
news:u6*************@TK2MSFTNGP12.phx.gbl...
Hi,

Using the app.config scenario and I added a Connectionstring to appSettings area in xml. In the value string I have the datasource equal to a absolute
path on my dev machine. Now how can I set it to be relative to where my
project gets deployed to? Do I use Application.Startup in the connection
string startup as so :

<appSettings>
<add key="myCon" value="{"Jet OLEDB:Database Password=;Data Source=" + Application.Startup + "EMSWinDB.mdb';Password=;"};
</add>
</appSettings>

Or is there a better way, more effiecent way of doing this?

Thanks,

JJ

Nov 15 '05 #2
string path = Server.MapPath(null);

Server.MapPath Returns the physical file path that corresponds to the
specified virtual path on the Web server. If path is null, MapPath returns
the full physical path to the directory containing the current application.

If you put your data in a "Data" sub directory on your site, then you will
want to use

string datapath = Server.MapPath("Data");

If your site is running on the server's "C:\inetpub\wwwroot\MySite"
directory then after the above call, datapath will contain
"C:\inetpub\wwwroot\MySite\Data".

--
Leit Rachsor
Nov 15 '05 #3
Hi Leit,

Sorry not to mention it but this is a Win form App not asp.net.

Thanks,

JJ

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
Oh! Sorry about that. I don't know what I was thinking.

Add "using System.IO;"

Then ...

string apppath = Path.GetDirectoryName(Application.ExecutablePath);

will do the same thing.

--
Leit Rachsor
Nov 15 '05 #5
Belay my last posting!

Now I feel like a real idiot. But I learned something today!

I have always used Path.GetDirectoryName(Application.ExecutablePath); to get
the application's startup path. I *NEVER KNEW* that
"Application.StartupPath" existed. It was all the way down at the bottom of
the Intellisense list. ;o)

cool.

In that case...

string datapath = Path.Combine(Application.StartupPath, @"Data\");

will do the same thing as my earlier posting.

--
Leit Rachsor
Nov 15 '05 #6

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

Similar topics

16
by: Neil Benn | last post by:
Hello, I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python...
4
by: acemann7 | last post by:
Windows 2000 udb v 7.2 Got the latest fixpak 13 Applied it. Still can't get a single java sp to run. I used to get reason "2"... now reason "0" - reason 0 is not even documented. I point...
0
by: Ariel Gimenez | last post by:
Hi, Does anyone know how to get the startup path of an assembly? this is my scenario: have a project with that generates a component wom is referenced in my web project this component needs to...
4
by: Larry | last post by:
I have a Perl script using DBD::DB2, that runs during system startup on a Solaris system. The script is working fine during startup on many machines, except on one machine it fails complaining...
3
by: New user | last post by:
How can I programmatically start a windows application when windows loads. Can I get the code to do that, I'd rather do it with code than with the setup & deployment wizard. I'd also like to be...
9
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... -...
12
by: rdemyan via AccessMonster.com | last post by:
I'm having a complicated linking problem. Before I get into the particulars, I'd like to know how Access links to the back-end file at startup, AFTER I've distributed my application to the client....
4
JodiPhillips
by: JodiPhillips | last post by:
MS Access2000 Hi everyone, I've searched the forums for an answer to this question and nothing jumps out at me. When a database is opened I want to automatically run code (at start-up) that...
10
by: kimiraikkonen | last post by:
Hi there, I figured out, for the first execution for any .NET-powered app such as VB.NET or C#, it takes 7-8 seconds to see main form of "any" application even the application consists of a single...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.