Link to home
Start Free TrialLog in
Avatar of imkiosks
imkiosks

asked on

Copying files with DLL's - Urgent

Hello all,
I have a VB.net (.net 2003) windows service which includes in it a C# .dll. This dll has a variety of responsibilites, among which is to copy a file from one machine to another. The code works perfectly except for the line of code which does the copying:
System.IO.File.Copy(sourceFilePath,targetFilePath,true);
I am using the System.IO.File object to do the copying. At the top of the dll, I have the "directive": using System.IO; The error I am getting is: Cannot find file...  but the file IS there. I wrote a quick sample windows forms application to copy the file, and it works fine. The windows service is running on the target machine, and the source file is sitting on another machine. Both are on their own private network. I am specifying the source path by using UNC:  \\10.1.1.1\SourceFolder\fileName.  Both machines have the same user account, for ease of accessibility, the source folder is shared, and I have gone through the sharing and security permissioning to make sure everything is right. Could this have something to do with the fact that I am trying to copy files from within a running windows service??  Do I need to add the Network Service user to something?
This is very high priority for me - I have a deliverable tomorrow. Hardware is being shipped out!
Any help would be appreciated. Thanks.
Avatar of cookre
cookre
Flag of United States of America image

The security context of a service is a bit different from user started programs, in that you have to specify, when you create the service, the account under which the service will run.

Also note that SystemLocal only has rights on the box it's running on.

ASKER CERTIFIED SOLUTION
Avatar of Corey Scheich
Corey Scheich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of imkiosks
imkiosks

ASKER

OMG,
Of course, of course, of course!!!!
I knew that. I have done just that many times before. Shame on me for overlooking such a simple setting. Well, when you're under pressure - nothing works right (i guess...  :-/ )

Thanks, Corey - you saved my butt.
No problem my pleasure