File Transfer using FTP - c#

I need to transfer a big file using FTP in my Windows application to remote machine.
I used command prompt to transfer files using FTP. But how can I do it programmatically
in .net 2.0. Sample program is advantage.

For this you could use: FtpWebRequest.
Here is a great example. I hate linking to another site, but it has an example with it for uploading and downloading using FTP.
http://www.c-sharpcorner.com/uploadfile/neo_matrix/simpleftp01172007082222am/simpleftp.aspx

Related

Write And Read .txt files from FTP with C#

Is it possible to write a txt file on ftp (not upload a file to ftp!) Directly writing a txt file on ftp server) and read from a file on a ftp (not download a file from ftp!) Directly read from a txt file on ftp server? I searched but ı found upload a file and donwload a file with FtpWebRequest class. Note: FTP server uses credentials.
No, it is not possible.
The FTP protocol described in RFC 959 doesn't have any means to achieve what you want.
No, as far as I'm aware, your only option is to download or upload the file. I guess you could short-circuit it a bit by only downloading the file until you got to the part you needed, then aborting. But the whole purpose of FTP is to upload/download FILES, not content.
It's possible with help of third-party virtual file system driver which should be installed in system. There exist third-party applications which let you see the remote FTP location as a virtual disk on your computer. Once the remote FTP location is mounted this way you can use regular file I/O methods to read and write those files. You can create such application as well (not a rocket science with right tools).

File Transfer between Computers Using Remoting/WCF

I need to UpLoad File/Folder from one Computer to another without using basic File Sharing how can this be done using WCF...
I have found Examples... like this but in this the File Transfer is between a Server and a Client....
In my Case any computer can be a server and others can be Client i.e the application can be invoked from any computer to transfer files between others... Can this be done... using Remoting/WCF...
I think WCF Peer-to-Peer is what you're looking for.

Uploading files to Linux server from Windows C#

I have to write a C# program that only needs to work on Windows. It needs to allow the user to select a file to upload. That file will be uploaded to a folder on a remote Linux server. I know the username, password, and url for this Linux machine. Does anyone know how I go about connecting to the server and then uploading the file to it in a C# desktop application?
If you're going to upload over FTP, the FtpWebRequest should do the trick:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
So I came up with this answer before looking at the first response (David's). Interestingly, we came up with the same solution! An ftp upload was what I was looking for. I completely forgot about FTP.
MSDN also has this web page for a more succinct how-to:
http://msdn.microsoft.com/en-us/library/ms229715.aspx

Send a xml file from windows to ubuntu

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.

How to correctly write dynamic files to an FTP server?

I'm using C# and i have written a locally installed application that dynamically generates files which need to be on an FTP server.
Do i generate them to disk then upload them to the FTP server? or is there a way to open a stream to an FTP server and write the files directly?
Check the code sample I gave in this answer, doesn't rely on writing to files. It's not SQL specific and was just a suggestion on how to use SQL CLR integration assemblies to upload output from sql queries to an FTP server. The for loop in the method is just to demonstrate writing to the FTP stream. You should be able to rework to you needs:
How to write stored procedure output directly to a file on an FTP without using local or temp files?
You should follow the class:
System.Net.FtpWebRequest
You will see that its arguments are streams and you can send data to them from any source.
When seaching for .Net capabilities you should be aware of the object browser for visual studio acessible in:
View > other windows > object browser
Is supplies a search over all known assembly .Net objects.
The better way is to save file locally, and upload it later, since there could be problems with upload process.
Since you are using c# I'm thinking maybe you are in a Windows Env. Something I know little about :)
If you are dealing with a unix env, you could just pipe your output thru SSH, which would also take care of encryption overhead.

Categories