Connecting Tech Pros Worldwide Forums | Help | Site Map

Why can't access a file under network drive from Windows Service?

Daniel Xiao
Guest
 
Posts: n/a
#1: Nov 16 '05
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 share, Int32 bufferSize, Boolean useAsync, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share)
at dump_tool.Dump_Load.run()


The source codes relevant are:

Cur_Fs = File.Open( Cur_File, FileMode.Open, FileAccess.Read,
FileShare.Read );

Where Cur_File = "o:\jul04\10\fares.fl", o: is a mapped network drive.





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Donald E. Hurley Jr.
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Why can't access a file under network drive from Windows Service?


Who is the Service running as? Typically if it is running as Local System,
it won't have access to network drives.

Hope this helps.

"Daniel Xiao" <xiaodan98@yahoo.com> wrote in message
news:#w$MurUaEHA.972@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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 share, Int32 bufferSize, Boolean useAsync, String
> msgPath, Boolean bFromProxy)
> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
> access, FileShare share)
> at dump_tool.Dump_Load.run()
>
>
> The source codes relevant are:
>
> Cur_Fs = File.Open( Cur_File, FileMode.Open, FileAccess.Read,
> FileShare.Read );
>
> Where Cur_File = "o:\jul04\10\fares.fl", o: is a mapped network drive.
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Daniel Xiao
Guest
 
Posts: n/a
#3: Nov 16 '05

re: Why can't access a file under network drive from Windows Service?


Exactly "local system". Which one should I use? In fact, I have tried
others, but failed in installutil every time.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Donald E. Hurley Jr.
Guest
 
Posts: n/a
#4: Nov 16 '05

re: Why can't access a file under network drive from Windows Service?


Try going to services and use your own username/pass. Just to see if that fixes the problem. I wouldn't suggest leaving it that way, because if you change your password in the future, your account will get locked out.

Donald Hurley

"Daniel Xiao" wrote:
[color=blue]
> Exactly "local system". Which one should I use? In fact, I have tried
> others, but failed in installutil every time.
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
>[/color]
Closed Thread