How to upload video file on ftp server using asp.net,C#.
I have large size video files. I want to upload it on the ftp server using ASP.Net,C#. How i will upload it. Please suggest me.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dhirendra MisraPosted Jan 14, 2014, 3:08 AM
Do you have FTP server with connection details? Try the following. It was working for me.
You need to update finger print in following example. Details for finger print:
http://winscp.net/forum/viewtopic.php?t=9493
http://winscp.net/eng/docs/faq_script_hostkey
http://winscp.net/eng/docs/library#csharp
using System;
using WinSCP;
class Example
{
public static int Main()
{ try
{ // Setup session options
SessionOptions sessionOptions = new SessionOptions {
Protocol = Protocol.Sftp,
HostName = "example.com",
UserName = "user",
Password = "mypassword",
SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" };
using (Session session = new Session())
{ // Connect
session.Open(sessionOptions);
// Upload files
TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);
// Throw on any error
transferResult.Check(); // Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName); } }
return 0; }
catch (Exception e) { Console.WriteLine("Error: {0}", e); return 1; } } }
Ikram ShamsPosted Jan 14, 2014, 12:26 AM
Dhirendra MisraPosted Jan 12, 2014, 10:36 PM
In order to upload / download files from FTP server there is good option of WINSCP. You can use FTP or SFTP protocol to upload the files.
http://winscp.net/eng/docs/library
There is rich documentation on this.
Thanks