Hi friends
I want had a question that how to connect to network system in C#.net ,
I had IP address,UserID and Password and i had to check whether there is a file in the Network Sytem
Thanks
Satish
Loading
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.
satish DandibotlaPosted Feb 8, 2008, 3:04 AM
{
string uri = "ftp://" + ftpaddress + "/" + fileInf.Name;
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Credentials = new NetworkCredential(username, password);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;
FtpWebResponse fb = (FtpWebResponse)reqFTP.GetResponse();
long cnlen = fb.ContentLength;
if (cnlen > 0)
MessageBox.Show("File is found");
}
catch(WebException ex)
{
// if(fw.StatusCode == FtpStatusCode.FileActionAborted)
//if(es.Status == FtpStatusCode.ActionNotTakenFileUnavailable)
FtpWebResponse fw = (FtpWebResponse)ex.Response;
if (fw.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
MessageBox.Show("File Not Found");
}
}