473,499 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access files from .NET Windows Service

Tom
Is it possible to access (Read via StreamReader) an external file from
a Wndows service? I.E. In the OnStart method of the service, I need to
go out and read a couple of external files (and these files appear on a
differnet server and are accessed via a UNC syntax - i.e.
\\server\share\myfile.txt). I tried this under my VB.NET service but it
keeps telling me that I have an unauthorized file access when my
service starts up)

Thanks.

--

Jul 17 '06 #1
3 1883
Sounds like a permissions issue. I'd create a user accout for the
service to use and give this user read\write permissions to the share.

Israel

Tom wrote:
Is it possible to access (Read via StreamReader) an external file from
a Wndows service? I.E. In the OnStart method of the service, I need to
go out and read a couple of external files (and these files appear on a
differnet server and are accessed via a UNC syntax - i.e.
\\server\share\myfile.txt). I tried this under my VB.NET service but it
keeps telling me that I have an unauthorized file access when my
service starts up)

Thanks.

--
Jul 17 '06 #2
Tom
Hmm... that is kinda ugly... Is there a way that I can simply add the
system account (the one the service is currently running under) to the
share's read/write permissions?
--

Izzy wrote:
>Sounds like a permissions issue. I'd create a user accout for the
service to use and give this user read\write permissions to the share.

Israel

Tom wrote:
>Is it possible to access (Read via StreamReader) an external file
from a Wndows service? I.E. In the OnStart method of the service,
I need to go out and read a couple of external files (and these
files appear on a differnet server and are accessed via a UNC
syntax - i.e. \\server\share\myfile.txt). I tried this under my
VB.NET service but it keeps telling me that I have an unauthorized
file access when my service starts up)

Thanks.

--
Jul 17 '06 #3
I've got 2 or 3 windows services and some other apps that need to
access network drives and databases. I find it easy to have them all
run under the same user account "Robot".

But if you don't want to go that route then just change the folders
permissions to allow anyone to read and write.

But if security is an issue, I'd set up a user account.
Tom wrote:
Hmm... that is kinda ugly... Is there a way that I can simply add the
system account (the one the service is currently running under) to the
share's read/write permissions?
--

Izzy wrote:
Sounds like a permissions issue. I'd create a user accout for the
service to use and give this user read\write permissions to the share.

Israel

Tom wrote:
Is it possible to access (Read via StreamReader) an external file
from a Wndows service? I.E. In the OnStart method of the service,
I need to go out and read a couple of external files (and these
files appear on a differnet server and are accessed via a UNC
syntax - i.e. \\server\share\myfile.txt). I tried this under my
VB.NET service but it keeps telling me that I have an unauthorized
file access when my service starts up)

Thanks.

--
Jul 18 '06 #4

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

Similar topics

6
2900
by: Rob | last post by:
Hi, I am working on a project that requires a Windows Service which performs the following file transfer functions. 1. It monitors a specific local directory on a Windows 2003 Server. 2. When...
4
6833
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...
16
7357
by: Brad | last post by:
After compiling my asp.net project I'm receiving a "BC31011 - Access is denied" error when attempting to run or debug. The only thing that seems to resolve problem is IISReset. After a reset my...
4
2897
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
11
45229
by: TheBurgerMan | last post by:
Hi all. I am using W2K3, .NET2 on a machine running AD and Exchange. I started getting the message below last week. I googled the error and not much was returned, but I did find this;...
3
3664
by: Doug Bailey | last post by:
I am trying to control a Windows Service via a Web Service interface. (I am developing in .NET2003) I am using the ServiceController object which allows me to read the state of the services with...
10
2958
by: Lyle Fairfield | last post by:
By default mdb etc files are not searched by Indexing Service. The default can be changed in Windows XP Pro using Group Policy. I can find no suggested way to make the change in the Windows XO...
21
2381
by: Bigpond News | last post by:
Work at a large site - 1000+ PC's. Mixture of Win98 & WinXP. Majority of applications using Access 97. If I compile the Acc97 application on a Win98 PC, the .mde will run perfectly on both...
4
21681
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
0
7130
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,...
0
7007
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
7171
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
5468
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,...
1
4918
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...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
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...

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.