473,761 Members | 10,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2484
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.co m

"DKode" <dk****@gmail.c om> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.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.co m

"DKode" <dk****@gmail.c om> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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.c om> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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******** ********@TK2MSF TNGP09.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

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

Similar topics

7
3245
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 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
5
28971
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 Novell server mapped drive) I created the Service with "LocalSystem" for the ServiceProcess.Account and it cannot find the G:\ drive.
1
3430
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 function to change the local path for downloaded files. If the configured path is different from local drive C: the new path is selected. The program works fine in debug or release mode into Visual Studio. All downloaded files were placed on remote...
3
13360
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 "NetworkService" don't work. i.e. it can't access the shared drive. But in "User" it can. But I don't want it in user mode, if possible. I would rather it be a service. Is there any way to do it?
1
9508
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 for accessing network drive in console apps, then call it with your windows service.. via windows API ..he..he that should work. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As...
3
2099
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. Every time I log in, I have to retype the password to connect to that network drive, so it isn't stored and thus the service cannot connect to the network drive.
3
5218
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” property of ServiceProcessInstaller to “Local Service” or to “NetWorkService”, it won’t work for both local and network shared directories. (I use log on as this account “NT AUTHORITY\LocalService” for “Local Service” or “NT...
4
11739
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 file or changes (to files or folders) then it copies the files (and any new folders) to a folder in the mapped network drive. So far I have been successful in developing and deploying the service which works on my local machine with two drives...
17
3218
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 changed the file path and everythng according to server drives. we all in the office share some network drives in which ppl will keep pasting that file and the service on server has to pick it up. which its not doing. when i paste it in netwrok...
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.