473,406 Members | 2,404 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,406 software developers and data experts.

.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 SetCurrentDirectory(...) 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 SetCurrentDirectory fall always in an Exception.

Anybody has an idea how can i resolve this issue?
Thanks.
Max
CODE -----------------------------------------------------------------------------------------------
public void chlocaldir(string dirName)
{
string drive = dirName.Remove(1,dirName.Length-1);
string path = dirName.Remove(0,2);

try
{
if ( drive != "C")
{
// Change Drive
Directory.SetCurrentDirectory(drive + ":\\");
// Change Path
Directory.SetCurrentDirectory(drive + ":" + path);
}
else
Directory.SetCurrentDirectory(drive + ":" + path);
}
catch(Exception e)
{
Directory.SetCurrentDirectory("C:\\");

throw new IOException("Can'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>vYfZDKECAU2njkPvbIpjlA==</Id>
Nov 16 '05 #1
1 3377
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

1
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...
3
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...
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...
4
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...
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...
6
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...
5
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
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...

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.