View Single Post
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Console App, Spawned From Service, File IO

 
0
  #2
Aug 25th, 2005
Is there no brave soul willing to take a stab at this? Let me re-hash it in case the above isn't clear.

I get the following error:

An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll

Additional information: Could not find a part of the path "z:\".
The code that causes the error (I'm using the "PHP" tags, but this is C# code, of course):

[PHP]if (!Directory.Exists(sack_destination + tape_name))
{
Directory.CreateDirectory(sack_destination + tape_name);
}[/PHP]

"sack_destination" is a string that equates to "z:\mer". This is a mapped drive, a network share.

The code is contained in a Console Application, which is launched from a Windows Service application using System.Diagnostics.Process.Start.

I have tried running the service under the LocalSystem account, and as a local user account with Administrative + "run as service" privileges. The same error in each case.

I also tried running the service under NetworkResource account, but the service failed to start, with no specific error message, so I'm not sure what the problem is there.

The error does NOT occur when I manually run or debug the Console application.

What privileges are needed in order for an application spawned by a service to access network resources? Can those privileges be granted programmatically? In other words, can the service launch the process with specific credentials? If so, how (code snippet)?
Reply With Quote