Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copying files with DLL's - Urgent

Posted on 2007-04-09
4
Medium Priority
?
247 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:imkiosks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 18879098
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.

0
 
LVL 13

Accepted Solution

by:
Corey2 earned 2000 total points
ID: 18879522
Change your service to run under the user instead of system
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sys_srv_logon_user.mspx?mfr=true

This will make any application that is run by the service run under the user.

Services by default run under the System account which doesn't have any access to network shares.
0
 

Author Comment

by:imkiosks
ID: 18881540
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.
0
 
LVL 13

Expert Comment

by:Corey2
ID: 18881860
No problem my pleasure
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question