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
Related
I'm creating a window service which will monitor the folder and upload files to server if any new files created.
Here I'll have only web URL with virtual directory , created via IIS. Is it possible to upload a file to server only with URL.
I've tried using webclient to upload, its throwing error
The remote server returned an error: (405) Method Not Allowed.
This was my sample code tried:
using (WebClient client = new WebClient())
{
client.UploadFile(targetURL, phscialpath);
}
Gave required permissions, to both IIS and physical path folder.
As far as I know, it's impossible to directly upload a file to the server directly.
Normally, we have two ways to upload the file to the IIS server. On way is hosting a application on the IIS and the application has the codes to save the file to the server.By using this way, you need have the enough knowledge to build the application by using ASP.NET , PHP or else. This will be a complex application.
The second way is using ftp. We will create a FTP application on the IIS server and then you could use FTP to transfer the file to the server. By using this way, you could directly save the file to the speicific folder by using url.
Details about how to build a IIS FTP server, you could refer to below aritlce:
https://learn.microsoft.com/en-us/iis/publish/using-the-ftp-service/creating-a-new-ftp-site-in-iis-7
More details about how to transfer the file to the ftp by codes, you could refer to this answer.
I want to upload files to server by giving file list in text file like
c:\file1.ext
c:\file2.ext
is this possible without using UploadFile control or form method in asp.net c# ?
Only if the server and client are on the same LAN or VPN, you can think of using this:
String source = #"c:\file1.ext";
String desctrination = #"\\SERVER\TRANSFERDATA\file1.ext";
File.Move(source, desctrination);
or
File.Copy(source, desctrination);
It's impossible to grab files from client's machine without using fileupload controls.
Http protocol doesn't allow to do that.
You could have file transfer on client's machine and it could send you those files, or you could have web service for uploading files, but you can't directly grab files from client's machine
If you want a quick and easy answer no, but there is no such thing as impossible!! you can do one of those options:
Creating WCF service and let client install it in his PC.
Using ActiveX.
in video link Below you can see that ASP.net application accessing point of sale device that plug to client PC, now if that application can access device, you can access the C drive..
Connect to POS device throw asp.net
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.
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.
Visual Studio 2008
I have a xml file I want to send to a ubuntu server.
Before I was using the following to save on the current machine in the application folder. However, the customer has changed and now wants to store it on a remote network ubuntu server.
dt.WriteXml(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Config.xml"));
What is the best way to send files across the network? Is it possible to send files from a windows machine to a ubuntu server machine?
Many thanks for any advice,
The easiest solution is probably to use a samba daemon and plain old file copying. If your customer wants to use the Ubuntu server as a file server, they may have already set this up.
Another option is to run an FTP daemon on the server and use the WebClient class to upload the file to it. You can use the WebClient.UploadFile method to upload a file to the server or WebClient.UploadString to upload the string directly, using the FTP STOR command.
The easiest thing to do is probably to SCP it onto the remote machine.
Run a samba daemon on the ubuntu server and you can use shared folders (SMB) to transfer the file.