How to map local drive to a remote server using C# - 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.

Related

Connect to Remote Oracle Database Using tnsnames.ora in shared directory in c#

I am developing a C# program that connects to an Oracle database located in an intranet computer. A tnsnames.ora file is located in a shared directory and have several connection options. How do I use this tnsnames.ora file to connect to the database.
The contents of the tnsnames.ora file may change and would be updated in the shared directory. Copying just the required connection string and using in within the code is not an option.
Users should be able to select desired connection option from the tnsnames.ora
The tnsnames.ora file is a configuration file that contains network service names mapped to connect descriptors for the local naming method, or net service names mapped to listener protocol addresses.
For more detail.
enter link description here

Access password protected shared network

How to read/write files in a shared network drive?
I am creating an application to upload files to the password protected shared network drive. When I run locally, the files are uploaded well. But, in the publish environment it throws:
Access to the Path '/shared network drive/' is denied
How to resolve this ?
Two ways:
1) Create a network drive connection to the remote machine (so it appears to your computer as "X:" for example) and save to that.
2) Use the full UNC path specification: //RemoteMachineName/SharedFolder/foldername

Copy or Write file to remote machine using wmi 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.

upload file to the network mapped drive in c#

I am using c# asp.net mvc 3 and entity framework to upload the file to the network drive mapped as Z drive. I have following c# code for determining file path:
var path = Path.Combine(Z:/upload/catone/", fileName);
aries.SaveAs(path);
I am using window server 2008 and IIS 7. I have also check Security of upload folder of network drive and have acess full control for EVERYONE user. If I changed file path to local drive, it works fine. But it shows following error while uploading to network drive (Z:/).
Could not find a part of the path
'Z:\upload\catone\_2013011504265221N_todaily.wav'.
Your code is running under IIS and thus is run with access privileges of the IIS user account which may not have access to that network drive.
You can try runnning the app pool under your identity for instance, to rule this issue out, or give full access to the group IIS_IUSRS to that folder.
First of all save the file in local machine ,
than after use file.copy(Source, Destination, true) method to save file in network drive.
try that it is helpful for you

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