Bad test if file on ftp exist
I have this problem: when i testing if file exist on ftp,I have exception
and the program write file dont exist...But when I write adress in
variable REQUEST into mozilla the file exist and in right format...Have
any idea where is the problem? My code:
private void TestGenerOrders()
{
//Testuje, zda-li soubor existuje
var c2 = (counter2).ToString().PadLeft(5, '0');
var request = (FtpWebRequest)WebRequest.Create((FtpZmeny) +
"orders" + (c2) + ".xml");
request.Credentials = new NetworkCredential(FtpNOHELJmeno,
FtpNOHELHeslo);
request.Method = WebRequestMethods.Ftp.GetFileSize;
try
{
FtpWebResponse response =
(FtpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
FtpWebResponse response = (FtpWebResponse)ex.Response;
if (response.StatusCode ==
FtpStatusCode.ActionNotTakenFileUnavailable)
{
MessageBox.Show("Error");
Prijem();
}
else
{
Prijem2();
}
}
}
No comments:
Post a Comment