I am using the SharpSsh to transfer the file to server using SFTP through ASP.NET.
Below is my source code. But I am getting the error!
using System.Collections;
using System.Threading;
using System.IO;
using Tamir.SharpSsh;
using Tamir.Streams;
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fuUploadFile.HasFile)
{
string _ftpURL = "ftp://22.00.333.444/";
string _UserName = "admin";
string _Password = "admin123";
int _Port = 22;
string _ftpDirectory = "/TestFTP";
string LocalDirectory =
Server.MapPath(fuUploadFile.PostedFile.FileName);
string FileName = fuUploadFile.FileName;;
Sftp oSftp = new Sftp(_ftpURL, _UserName, _Password);
oSftp.Connect(_Port);
oSftp.Put(LocalDirectory , _ftpDirectory + "/" + FileName);
oSftp.Close();
}
}
When i try to run the code i am getting the following exception please help me how to fix this exeception.
System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found
at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
at System.Net.Dns.GetHostByName(String hostName)
at Tamir.SharpSsh.java.net.Socket..ctor(String host, Int32 port)
at Tamir.SharpSsh.jsch.Util.createSocket(String host, Int32 port, Int32 timeout)