473,226 Members | 1,519 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,226 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 2436
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Anders | last post by:
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...
5
by: Anthony Boudouvas | last post by:
Hi to all, is there a way to access a mapped network drive from a Windows Service application ? I created a very simple one, using a timer that checks for a file existance on G:\Emails (a...
1
by: Max Baki via .NET 247 | last post by:
I all, i've write a sample ftp Windows service which download files and copy them on remote share or remote mapped drive (the service works fine on local drives). This part of code is the...
3
by: Bonj | last post by:
I need to write a windows service, and the only way it can access a shared drive on a file server on the network is if the installer is put in "User" mode - "LocalService", "LocalSystem" and...
1
by: mbah Sumani via .NET 247 | last post by:
(Type your message here) I Think it's the stupidness of Windows. Why the service can't access network drive but console apps or windows application can do it? So my suggestion is make the program...
3
by: Brecht Yperman | last post by:
Hi, I am running a .NET application as a Windows Service. In that application I create a FileSystemWatcher. I want it to watch a network drive which maps to an IBM iSeries IFS directory....
3
by: Miriam | last post by:
Hello, I created a Windows Service in VB.NET, which is to purge files periodically in the local system and also in the shared network drive. Here is my problem: 1. If I set the “Account”...
4
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new...
17
by: ayush patel | last post by:
Hi all, I have created a windows service that has a file watcher and does some operation after it reads that file. i developed it in my local machine and installed the service on server. i have...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.