Copy or Write file to remote machine using wmi c# - c#

I have to file copy/write to my remote machine(client) which is connected through my domain(server).
I had been work out with wmi copy function.but it helps only to copy the file from remote machine to local machine.
but I want write my files into remote machine windows directory.Please provide the way i can achieve my requirement using wmi c#.Thanks

If you have the required privileges to do so through WMI, you can simply use the administrative shares and do it the normal way.
For example, copying a file to the computer server1 into the D: partition into the folder named Folder1, you would do
copy yourfile.dat \\server1\d$\folder1\yourfile.dat
or use any other way to create a file there. The path name is valid for any method to create files.

Related

How to map a network drive on a remote system in C#

I am using MapNetworkDrive Method of the WshNetwork object. I am able to map a network shared folder as a drive on my computer through the code. But my real objective is to map a network drive in a remote computer to a shared folder on my computer. How is this done?
You can use WMI to create a remote process and send a console command to map that drive
You could also use PsExec if WMI does not work for you.

How to map local drive to a remote server using C#

I need to distribute a local msi installer to a number of remote servers.
I assume, that the way to do it is to map my local drive (on which the msi is located) to those remote servers and then copy this file from the mapped local drive onto a specific directory of each server.
At firs, I was trying to copy file to a remote server without doing any prior mapping:
System.IO.File.Copy(#"\\WIN-J02JG3AAV7P\temp\emcrpts_x64_v40.msi",
#"\\sharepoint2010\C$", true);
this did not work (error: the network path was not found)
Then, I'm trying to map my local drive to a remote server, but I'm lacking the proper syntax.
If I have a local C:\temp shared, what is the proper C# syntax to map it to a remote server named "sharepoint2010"?
Appending a file name to the destination could already fix your problem:
File.Copy(#"\\WIN-J02JG3AAV7P\temp\emcrpts_x64_v40.msi",
#"\\sharepoint2010\C$\emcrpts_x64_v40.msi", true);
The destination can't be a directory, see the documentation.

How to move or copy a file/directory from my computer to ather computer?

I have a program in C# which i can move and copy files and directories by compress or by not compress between two path in a computer, but i want to do this between two computer. I want to use as target path of other computer's driver. How can i do this?
Thanks for your helps,
Theres a couple of ways you could do this,
Setup a FTP Server on the other side using a FTP component
Directly connect to the other machine using a UNC Path
Use a SCP style system if the machine is a unix box
Setup a file transfer protocol of your own (ie send a bytestream over the network).
I would strongly recommend using a pre-existing protocol though, such as FTP, that way you can re-use libraries and it promotes inter-op with other programs.

File.Copy from Unc path to (same server's) Unc path inquiry

Will data traffic go through the host application program or will be dealt remotely in scenarios where C#'s File.Copy is used:
File.Copy(#"\\SERVER13\LOL\ROFL.txt", #"\\SERVER13\ROFL.txt")
Cheers n thx!
First of all you have a small bug in the path of the destination file.
Second, there are no remote copy operation. There exist a remote move operation (rename, but with a destination in other directory) like MoveFile (see native API http://msdn.microsoft.com/en-us/library/aa365239%28VS.85%29.aspx).
UPDATED: Probably you came from unix and knows utility rcp, but it works with respect of remote shell service (rshd) and not with respect of direct file system features. You can also use PsExec utility from SysInternals (see http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) to start some program on the remote computer, but all this is not a subject of programming.
It will go through the local application. The file system does not know what the application is going to do with the bytes it reads from the share, or where the bytes that are written to the share come from.
In addition, the application does not know (in the case of DFS) if the two shares are on the same machine.
If you want to let the server handle it, you have to remotely run a copy program.

Move zip file between servers using C#

I want to move the zip file from one server to another server.
What is the best way to do that using C#?
If i am on my local machine running my C# application.
And I want to access two servers server A and serverB using File.COpy() to transfer the file from A to B then it is giving me credential issue.
I don't know whether I have UNC share for both the servers.
I want to use webrequest to transfer the zip file from Server A to Server B from my machine.
If you have a UNC share on the destination server, you can just use
System.IO.File.Copy(String sourceFileLocation,
String destinationFileLocation)
Otherwise you have to simply FTP it.
http://www.devasp.net/net/articles/display/280.html

Categories