Hi all,

can anybody please tell me whether is it possible that through windows service we can able to move file from one machine to another....???

what i made is
first i checked with normal windows application ,by creating a mapped drive to my machine.
ex:- Y:\ and i was able to move files to another machine(which is a mapped drive\folder).

second i made it as an .exe which runs as a process ,this also works fine.

but through windows service i am not able to do .....
i tried another option as file.copy to mapped folder then delete the file in local system
but this also doesn't worked.
windows service is specific to one machine is it true....?

please help me if i can move the file from one machine to another using windows service..

Thanks in advance
naresh.

Recommended Answers

All 7 Replies

Yes you can do this. I have a service that does this type of work for archiving files.
Remember that a mapped drive is in the context of the currently logged on user. A Windows service runs in its own context. So, your mapped drive may not be visible to the windows service account.
If the service account has the security rights to the remote machine, then you can perform IO with it using the fully qualified path.

I use a fully qualified path instead of a mapped drive. You may have to either have your service create the mapping on startup, or just use the full path.

Yes you can do this. I have a service that does this type of work for archiving files.
Remember that a mapped drive is in the context of the currently logged on user. A Windows service runs in its own context. So, your mapped drive may not be visible to the windows service account.
If the service account has the security rights to the remote machine, then you can perform IO with it using the fully qualified path.

I use a fully qualified path instead of a mapped drive. You may have to either have your service create the mapping on startup, or just use the full path.

Hi thank you for your suggestion,can you please provide a me a example.
or let me know how to make a service account to have security rights on remote machine where that account will not exists.

The account must exist on the remote computer, or in the active directory where that account has rights to the computer.

Optionally, you can use impersonation of an existing account on the remote pc.

Even though it is a service account, it still must comply with all Windows security requirements.

//Jerry

Hi Thanks A lot long back i solved it i forgot to close but anyhow now i am with one more issue.
But now i a m facing problem with network.

when the network goes down and comes up it is not working the windows service is getting stopped(operation)

i am trying this link http://www.codeguru.com/csharp/.net/net_general/eventsanddelegates/article.php/c9113
i am not able to fix.let me check thoroughly and get back.
if you have any suggestion pls let me know.
Naresh

Hi Now it's working Thanks a lot i am marking the post as solved.

Hi,

I want to move files between two machines can you please pass me the logic or code to do it.

Thanks in advance

Thanks
Nani

If the other machine has a directory marked as shared you can just use the System.IO name space and the File.Move or File.Copy methods. Then use the fully qualified directory path

System.IO.File.Copy( "C:\\MyFile.txt", @"\\machine\sharepath\MyFile.txt");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.