473,387 Members | 1,561 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,387 software developers and data experts.

dynamic path

My service is running fine
when i give full path like this
"E:\c# windows\clamservice\bin\Release\database"

but when i tried for dynamic

"/database"

it compiles well but when i go to Computer Management ->Services and start
it ,it gives

"The clamservice on local computer started and then stopped.Some services
stop automatically
if they have no work to do,for example performance logs and alerts service"
Feb 14 '06 #1
6 9120
Hi

Windows Service has a different initial Working directory.
Debug.WriteLine(Environment.CurrentDirectory.ToStr ing());
The result will be C:\WINDOWS\system32, the result may differ according to
where you install Windows.

That is to say it will check the C:\WINDOWS\system32 for the relative path.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 14 '06 #2
i tried like this

pathdb=Environment.CurrentDirectory.ToString();

pathdb=pathdb+@"\database";

p.Database.Path=pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=ConfigurationSettings.AppSettings.Get("dbpa th");

it runs fine

""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:D9**************@TK2MSFTNGXA01.phx.gbl...
Hi

Windows Service has a different initial Working directory.
Debug.WriteLine(Environment.CurrentDirectory.ToStr ing());
The result will be C:\WINDOWS\system32, the result may differ according to
where you install Windows.

That is to say it will check the C:\WINDOWS\system32 for the relative
path.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 14 '06 #3
Ankit Aneja wrote:
i tried like this

pathdb=Environment.CurrentDirectory.ToString();

pathdb=pathdb+@"\database";

p.Database.Path=pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=ConfigurationSettings.AppSettings.Get("dbpa th");

it runs fine


As Peter said, the CurrentDirectory property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\System32, which I really hope you haven't...

You might want to look at Assembly.GetExecutingAssembly() and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetModule(), then Module.FullyQualifiedName.)

Jon

Feb 14 '06 #4
can u give me code example
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ankit Aneja wrote:
i tried like this

pathdb=Environment.CurrentDirectory.ToString();

pathdb=pathdb+@"\database";

p.Database.Path=pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=ConfigurationSettings.AppSettings.Get("dbpa th");

it runs fine


As Peter said, the CurrentDirectory property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\System32, which I really hope you haven't...

You might want to look at Assembly.GetExecutingAssembly() and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetModule(), then Module.FullyQualifiedName.)

Jon

Feb 14 '06 #5
thanks
solved
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ankit Aneja wrote:
i tried like this

pathdb=Environment.CurrentDirectory.ToString();

pathdb=pathdb+@"\database";

p.Database.Path=pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=ConfigurationSettings.AppSettings.Get("dbpa th");

it runs fine


As Peter said, the CurrentDirectory property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\System32, which I really hope you haven't...

You might want to look at Assembly.GetExecutingAssembly() and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetModule(), then Module.FullyQualifiedName.)

Jon

Feb 14 '06 #6
pathdb=System.IO.Path.GetDirectoryName(System.Refl ection.Assembly.GetEntryAssembly().Location);

pathdb=pathdb+@"\database";

solved

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
can u give me code example
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Ankit Aneja wrote:
i tried like this

pathdb=Environment.CurrentDirectory.ToString();

pathdb=pathdb+@"\database";

p.Database.Path=pathdb;

but still at time of start it starts and then stops

and when using hardcoded path from config file

//pathdb=ConfigurationSettings.AppSettings.Get("dbpa th");

it runs fine


As Peter said, the CurrentDirectory property won't be what you expect -
unless you really *have* got a directory called "database" under
c:\Windows\System32, which I really hope you haven't...

You might want to look at Assembly.GetExecutingAssembly() and work out
where the assembly is, so you can make a path relative to that. (You
can find the path using
Assembly.GetModule(), then Module.FullyQualifiedName.)

Jon


Feb 14 '06 #7

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

Similar topics

3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
2
by: Justin | last post by:
Hi, I m doing a windows program using VB.net for my school assignment. I would like to ask is there a way for me to set a path (eg: //SamPC/data) as something dynamic such as dynamic...
1
by: Director - Minvent | last post by:
I am having a problem! I am using the Task Pane control which MS gave out in their VBPowerPack. If I add an image to the task frame I have to use a physical path e.g. c:\connected.bmp as...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
8
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able...
1
by: liam_herron | last post by:
I have compiled my boost-enabled C++ module and have it working when I explicity set my LD_LIBRARY_PATH before invoking the python2.4 interpreter. Now I don't want everyone to have to set this...
4
by: Deere | last post by:
When I try to take a database field and change it with a function and return it...it will not display the image. The "Imageurl" does not convert to "src=" but stays as ImageUrl. id=Image2 will...
6
by: Bill Spotz | last post by:
Hi, Is there a way to tell an executing python script where to look for dynamically-loaded libraries? My situation is that that I am developing python wrappers for a large software project. ...
4
by: aarklon | last post by:
Hi all, recently a friend asked me is there any dynamic binding in C...?? to which i answered AFAIK it is in C++ only, but he says it is valid in C. if dynamic can be implemented via function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.