473,581 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET Windows Service accessing network drive problem

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 share or remote mapped drive.

On Installed Service the SetCurrentDirec tory(...) eg.. 'H:\' which is on remote server fall in an Exception. Same if the directory is a remote unc path like '\\server\root' .

I tried to install the service like System Account, Network Account or User Account granted to shares, but the SetCurrentDirec tory fall always in an Exception.

Anybody has an idea how can i resolve this issue?
CODE -----------------------------------------------------------------------------------------------
public void chlocaldir(stri ng dirName)
string drive = dirName.Remove( 1,dirName.Lengt h-1);
string path = dirName.Remove( 0,2);

if ( drive != "C")
// Change Drive
Directory.SetCu rrentDirectory( drive + ":\\");
// Change Path
Directory.SetCu rrentDirectory( drive + ":" + path);
Directory.SetCu rrentDirectory( drive + ":" + path);
catch(Exception e)
Directory.SetCu rrentDirectory( "C:\\");

throw new IOException("Ca n't connect to Remote Drive: " + e.Message);

this.localPath = drive + ":" + path;


CODE ------------------------------------------------------------------------------------------------
From: Max Baki
email: mb*@email.it

Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>vYfZDKECAU2 njkPvbIpjlA==</Id>
Nov 16 '05 #1
1 3399
Hi max
may be it is a security issue , do you know under with account does you
service run ? may be it is an account that lakes the right privileges
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2

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

Similar topics

by: Daniel Xiao | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004 10:24:48 AM run() error: System.IO.IOException: The specified network password is not correct. at System.IO.__Error.WinIOError(Int32 errorCode,...
by: Daniel Xiao | last post by:
I write a program accessing files in network drive o:. It is doable as a standalone application. However, if it is running under windows service, the following exception will appear: 13/07/2004 10:24:48 AM run() error: System.IO.IOException: The specified network password is not correct. at System.IO.__Error.WinIOError(Int32 errorCode,...
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...
by: marc.gibian | last post by:
I am writing a small Windows Service in C#. It is structured as two C# programs, one, let's call it myAction, that runs as a command line program and a second, let's call it myWrapper, that is the actual windows service, which starts the first program as a child process (and then waits for the child process to terminate, restarting it should...
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...
by: Bijesh | last post by:
Hi All, I've developed a Windows Service that acts as a remoting server (.NET Remoting). The client(user) is able to connect to the server and start a program by giving the executable path of the program (in the server) along with the working directory and the arguments (parameters). This works fine if I try to start programs whose...
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a seperate files server. we have mapped the fodler to a different folder and need to allow the EXE to process on the mapped drive. When I trigger the EXE via...
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....
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...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
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...
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...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.