473,387 Members | 1,844 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.

Windows Service, I/O problems?!

Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted
folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as
User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(

Any ideas?!

Cheers

//Anders =)
Nov 15 '05 #1
7 3215
To access the network from within a Window Service, you definitively cannot
start the Service with System account. This will not work.

Now, If you start it using your own account name, are you positive that the
x: drive is mounted and seen as such by your service?

José
"Anders" <an*************@banqsoft.se> wrote in message
news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted
folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as
User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(

Any ideas?!

Cheers

//Anders =)

Nov 15 '05 #2
Anders, could you try using a UNC path instead of a mapped drive? ie.
\\servername\fileshare\

--
Greg Ewing [MVP]
http://www.citidc.com/
"Anders" <an*************@banqsoft.se> wrote in message
news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted
folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as
User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(

Any ideas?!

Cheers

//Anders =)

Nov 15 '05 #3
Greg:
Thanx for your reply,
I have tried using the UNC path instead and it works. But I do not know
if this is because I already has the drive mappped. I have tried
installing my service on another machine, and then it doesn't work with
the UNC path either.

José:
Thanx for your reply,
I do not really understand what you mean with your question.
"Now, If you start it using your own account name, are you positive that
the
x: drive is mounted and seen as such by your service?"

//Anders =)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4
Greg:
thanx for your reply,
I have tried using the UNC path instead, and that works
fine. But I don't know if this is because I already have
the drive mapped...

José:
thanx for your reply,
Yes, I'm sure the drive is mounted....but what do you
mean with "...and seen as such by your service?"

//Anders =)
-----Original Message-----
Anders, could you try using a UNC path instead of a mapped drive? ie.\\servername\fileshare\

--
Greg Ewing [MVP]
http://www.citidc.com/
"Anders" <an*************@banqsoft.se> wrote in message
news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(
Any ideas?!

Cheers

//Anders =)

.

Nov 15 '05 #5
If was wondering if the x:\ drive is seen as mounted by your service.
To get a list of drive currently reachable by your application you can
execute Environment.GetLogicalDrives()
(refer to online help for a sample).
You could run it from within your service just to check it is available.

José
"Anders" <an*************@banqsoft.se> wrote in message
news:06****************************@phx.gbl...
Greg:
thanx for your reply,
I have tried using the UNC path instead, and that works
fine. But I don't know if this is because I already have
the drive mapped...

José:
thanx for your reply,
Yes, I'm sure the drive is mounted....but what do you
mean with "...and seen as such by your service?"

//Anders =)
-----Original Message-----
Anders, could you try using a UNC path instead of a mapped drive? ie.\\servername\fileshare\

--
Greg Ewing [MVP]
http://www.citidc.com/
"Anders" <an*************@banqsoft.se> wrote in message
news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(
Any ideas?!

Cheers

//Anders =)

.

Nov 15 '05 #6
Frankly, I'm not sure I'm correct. However, I believe that mounted drives
are allocated per user session (I believe that if you mount a drive on one
user account, it will not be seen on another user account)

To test this, you could run "cmd.exe" using different users (assuming you
have W2k or XP, press Shift and right mouse click on cmd.exe and choose
'runas').
In one dos shell, mount some drives and check if they are seen by the other
user.
José
"Anders" <an*************@banqsoft.se> a écrit dans le message de
news:01****************************@phx.gbl...
Hi José,

I tried to list all logical drives from my service - and
you were right, none of my mounted drives were listed...
(I got quite a few drives mounted). Do you know why?

I tried running the service with both Local System and
User (with my account) - no difference...

//Anders =)
-----Original Message-----
If was wondering if the x:\ drive is seen as mounted by your service.To get a list of drive currently reachable by your application you canexecute Environment.GetLogicalDrives()
(refer to online help for a sample).
You could run it from within your service just to check it is available.
José
"Anders" <an*************@banqsoft.se> wrote in message
news:06****************************@phx.gbl...
Greg:
thanx for your reply,
I have tried using the UNC path instead, and that works
fine. But I don't know if this is because I already have
the drive mapped...

José:
thanx for your reply,
Yes, I'm sure the drive is mounted....but what do you
mean with "...and seen as such by your service?"

//Anders =)
-----Original Message-----
Anders, could you try using a UNC path instead of a

mapped drive? ie.
\\servername\fileshare\

--
Greg Ewing [MVP]
http://www.citidc.com/
"Anders" <an*************@banqsoft.se> wrote in message
news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and onemounted folder (e.g. x:\).
All this works fine, but....when I run this application as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" andas User (logged on as me) so the process will run as the
same as the console app.....but there is no difference=(
Any ideas?!

Cheers

//Anders =)

.

.

Nov 15 '05 #7
You need to impersonate when accessing Network resources from Windows services running with local account credentials.

Willy.

"Anders" <an*************@banqsoft.se> wrote in message news:0a****************************@phx.gbl...
Hi all,

I have an console app that looks in one folder (e.g.
c:\temp) and copies all files to a couple of other
folders, one local folder (e.g. d:\temp) and one mounted
folder (e.g. x:\).
All this works fine, but....when I run this application
as a Windows Service the System.IO.File.Copy
(file,newFile,true) throws an
System.IO.DirectoryNotFoundException saying: Could not
find part of the path "x:\newFile.ext"

I have tried running the service as "Local System" and as
User (logged on as me) so the process will run as the
same as the console app.....but there is no difference =(

Any ideas?!

Cheers

//Anders =)

Nov 15 '05 #8

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

Similar topics

7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
2
by: Jesper Stocholm | last post by:
I have created a simple service which just copies a fil to a new file with a new name on certain intervals (the service implements a timer). I have no problems installing the service and the...
1
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL...
0
by: myoungbl | last post by:
Note:I'm using VB.NET, .NET 2.0, to write a service application. So far I've only attempted to run it on the development machine. I'm have a couple of problems I can't quite figure out with a...
6
by: Chris Marsh | last post by:
All I have a database table, changes to the data within which I am interested in acting on. The approach that I'm taking is to have the database update a file every time data is updated. This...
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
2
by: Andez | last post by:
I've wrote a windows service that performs simple functions within our application. To ensure safe running of the service - if it errors we want to know where when how - it logs to a text file - in...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
2
by: =?Utf-8?B?SnVzdCBjbG9zZSB5b3VyIGV5ZXMgYW5kIHNlZQ== | last post by:
Hello all i am trying to learn how to program a windows service application i had add an event log and a timer that used to write to file here is the code protected override void OnStart(string...
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: 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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.