Hi Christoffer,
What error are you getting?
For what it's worth, I created a standard .NET service, added an
installer component, added File.Move in the OnStart method and made
the target directory a UNC path, like so:
File.Move(@"c:\temp\foo.txt", @"\\myserver\share\subdir\foo.txt");
When I installed the service, I entered my domain user/password. When
I start the service, the file is moved just fine. Perhaps you could
do the same exercise, or at least post the error you're getting?
John- Dölj citerad text -
- Visa citerad text -
Hi John,
This is the code:
string mysource =
@"C:\Documents and Settings\tcncc\My Documents\Visual Studio
2005\Projects\MoveService\MoveService\bin\Debug
\2007-01-10_Designtidning_01.pdf";
string mytarget =
@"\\Tcn4fs1\Gemdata\CC\2007-01-10_Designtidning_01.pdf";
File.Move(mysource, mytarget);
And this is the error:
System.UnauthorizedAccessException: Access to the path is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.Move(String sourceFileName, String destFileName)
at MoveService.Service1.OnElapsedTime(Object source,
ElapsedEventArgs e) in C:\Documents and Settings\tcncc\My Documents
\Visual Studio 2005\Projects\MoveService\MoveService\Service1.cs:line
51
And the permissions to the network drive is:
Full Control Yes
Modify Yes
Read & Execute Yes
List Folders Contents Yes
Read Yes
Write Yes
Special Permissions No
The permission is the same as on my local drive, and move from c:\here
to c:\there works ok.
// Christoffer