473,395 Members | 1,680 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,395 software developers and data experts.

Validate network path in windows service

Hi

I have developed a windows service using C#. I am checking a folder
path using "DirectoryInfo" class which is in local network. It always
returns false, even folder exists on local network.

folderPath = "\\MyServer\IO\XYZ_Folder";
DirectoryInfo di = new DirectoryInfo(folderPath);
return di.Exists; //This returns false

Above code works properly, when I use inside windows application. Can
any body tell me the problem of Windows Service?

Thanks in advance.

Regards
Rajeev

Nov 17 '05 #1
4 11857
Hello Rajeev,

Is it a rights issue? What account is running the windows service?
Hi

I have developed a windows service using C#. I am checking a folder
path using "DirectoryInfo" class which is in local network. It always
returns false, even folder exists on local network.

folderPath = "\\MyServer\IO\XYZ_Folder";
DirectoryInfo di = new DirectoryInfo(folderPath);
return di.Exists; //This returns false
Above code works properly, when I use inside windows application. Can
any body tell me the problem of Windows Service?

Thanks in advance.

Regards
Rajeev

Nov 17 '05 #2

"Rajeev" <ra************@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi

I have developed a windows service using C#. I am checking a folder
path using "DirectoryInfo" class which is in local network. It always
returns false, even folder exists on local network.

folderPath = "\\MyServer\IO\XYZ_Folder";
DirectoryInfo di = new DirectoryInfo(folderPath);
return di.Exists; //This returns false

Above code works properly, when I use inside windows application. Can
any body tell me the problem of Windows Service?

Thanks in advance.

Regards
Rajeev


That means that the service identity has no access to the remote share.
There are several ways to tackle this issue, or you can create a logon
session (search MSDN for LogonUser and Impersonate for a sample) and
impersonate a user account that has the appropriate access rights, or you
can run the service as a user that has appropriate access rights to the
remote resource.

Willy.
Nov 17 '05 #3
Dear Brian

I don't think it is rights issue, because both machines are accessible
without any userid/password. Even I create Map network drive then also
Windows Service is not able to access. Windows Service is running under
Administrator account.

Thanks & Regards
Rajeev

Nov 17 '05 #4

"Rajeev" <ra************@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Dear Brian

I don't think it is rights issue, because both machines are accessible
without any userid/password. Even I create Map network drive then also
Windows Service is not able to access. Windows Service is running under
Administrator account.

Thanks & Regards
Rajeev


The windows service runs under "administrator" doesn't mean anything, it
runs in it's own logon session which is separate from the interactive
"administrator" logon session. Network connections are tied to their logon
sessions, not to the logon account.

Willy.
Nov 17 '05 #5

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

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
8
by: Leo R | last post by:
Hi, Is it possible to create a network-drive at the SYSTEM-level? E.g.: map X: to \\server1\share so a windows service can reach X: without having to log on? I want a Windows .NET service to...
5
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to 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...
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...
0
by: Chris | last post by:
Hello, I have writen a windows service accessing files on a shared network drive. I configured the service running under a network account which can access the network share. But, when my...
2
by: Mike | last post by:
Can a vb program running as a serice not use network paths to do file/io? I can't seem to get my program to work with network paths and files. When I use local disk it works fine. When I run it...
2
by: Michael | last post by:
We have an ASP.NET 2.0 web application running on a Windows 2003 domain controller. Part of that application needs to read and write files from and to a network share ( living on a MAC Xserveraid)...
3
by: =?Utf-8?B?cm9nZXJfMjc=?= | last post by:
hey, I've seen this problem many times over the net, and now I'm one of them. simple code really. File.Move(RemoteFolder, MoveImportedFilesTo); where RemoteFolder =...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.