473,387 Members | 1,379 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 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 2455
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: 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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...

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.