471,327 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Windows service and net drive

Hi, I'm in troubles with Windows XP SP_2

I've mapped a net drive to Z: for the machine user Administrator.

I've build a Windows service in C# and .NET Framework 1.1. This service

must copy several files to this net drive and for that, I use de

Administrator account on the machine.

And here is the problem: File and Directory classes don't allow me to

access Z:

Somebody can help?

P.D.: If I run the app in console mode instead of a Windows service, all

works fine.

Regards and thanks.
Feb 6 '06 #1
10 2374
Mapped drive letters are not supported in .NET as far as I know.

You have to use the UNC path.

Example:
if you have a Z drive mapped to \\server\share$\

then in your service app, you would use the path of \\server\share$\

That's how I have always done it and it works.

Feb 6 '06 #2
Mapped drive letters absolutely are supported in .NET...
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DKode" <dk****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Mapped drive letters are not supported in .NET as far as I know.

You have to use the UNC path.

Example:
if you have a Z drive mapped to \\server\share$\

then in your service app, you would use the path of \\server\share$\

That's how I have always done it and it works.

Feb 6 '06 #3
oh,

i was always under the impression that you ALWAYS need to use the UNC
path when accessing network resources

Feb 6 '06 #4
It depends on what you are using to perform the access. As a general
rule, I stick with UNC names over mapped drive letters (because those
mappings have a tendency to change more frequently than UNC names, IMO).

However, .NET fully supports them because the OS supports them. What
else is a drive mapping but an abstraction over a network share?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"DKode" <dk****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
oh,

i was always under the impression that you ALWAYS need to use the UNC
path when accessing network resources

Feb 6 '06 #5
this is true. Thanks for clearing that up for me. Now i know, and thats
half the battle :)

Feb 6 '06 #6
You will need to use a network account to access a network drive, not
the administrator for the machine.

hth,
Alex

Feb 6 '06 #7
G.I. Joe... Slick...
"DKode" <dk****@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
this is true. Thanks for clearing that up for me. Now i know, and thats
half the battle :)

Feb 6 '06 #8
:)

Feb 6 '06 #9
Connections with remoted shares are session bound, a Service doesn't share
the session with the logon user, that means you need to "map the drive" from
withing your Service, or better don't use mapped drives, use UNC paths
instead.
Mapped drives are for backward compatibility only, new developments should
never use these.

Willy.
"Ruben Fdez." <ru***@ruben.es> wrote in message
news:ur****************@TK2MSFTNGP09.phx.gbl...
| Hi, I'm in troubles with Windows XP SP_2
|
| I've mapped a net drive to Z: for the machine user Administrator.
|
| I've build a Windows service in C# and .NET Framework 1.1. This service
|
| must copy several files to this net drive and for that, I use de
|
| Administrator account on the machine.
|
| And here is the problem: File and Directory classes don't allow me to
|
| access Z:
|
| Somebody can help?
|
| P.D.: If I run the app in console mode instead of a Windows service, all
|
| works fine.
|
| Regards and thanks.
|
|
Feb 6 '06 #10
Hi,

"DKode" <dk****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
oh,

i was always under the impression that you ALWAYS need to use the UNC
path when accessing network resources


No really, as Nicholas said a network drive looks like any other drive local
to your system.

The catch is that the service is not connected to the logged user session.
and the network drives are !.
So the service does not see the mapped drive as this is local to each of the
potential logged users.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 6 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Anders | last post: by
5 posts views Thread by Anthony Boudouvas | last post: by
1 post views Thread by Max Baki via .NET 247 | last post: by
3 posts views Thread by Bonj | last post: by
1 post views Thread by mbah Sumani via .NET 247 | last post: by
3 posts views Thread by Brecht Yperman | last post: by
reply views Thread by rosydwin | last post: by

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.