473,757 Members | 5,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validate network path in windows service

Hi

I have developed a windows service using C#. I am checking a folder
path using "DirectoryI nfo" 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(f olderPath);
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 11951
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 "DirectoryI nfo" 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(f olderPath);
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******** *************@g 14g2000cwa.goog legroups.com...
Hi

I have developed a windows service using C#. I am checking a folder
path using "DirectoryI nfo" 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(f olderPath);
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.goo glegroups.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 "administra tor" doesn't mean anything, it
runs in it's own logon session which is separate from the interactive
"administra tor" 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
3654
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 my settings if my profile became tampered with or corrupt. Is there any sample code available out there? -Robert
8
5188
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 collect files from a UNIX-share (mapped to X:) that is exposed to windows using Hummingbird-software. Leo.
5
21570
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 folder on mapped network drive (eg. N:\Storage that corresponds to \\FS1NS\SharedDir\), I get an error as "Could not find part of path N:\".
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...
1
2398
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, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare...
0
1258
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 service is running and try to access the file an exception is thrown: Exception: System.IO.IOException Message: Logon denied: unknown user or wrong password.
2
1984
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 as a none service program it works fine. I'm assuming that vb programs running as a service do not support network paths. Is that true? Thanks in advance.
2
2423
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) on the same network segment. I mapped a drive on the server to that share. When mapping the drive, I could enter access credentials for the shares (an account from the Mac side that does not exist in the windows domain). Using Windows Explorer,...
3
7746
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 = \\192.168.1.99\ftp2users\monday\original1.csv and MoveImportedFilesTo = C:\wow.csv
0
9487
marktang
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
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
10069
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
9904
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...
0
8736
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
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
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.