Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input string format is not correct in ftp web request

I am creating a file on ftp server. But Before creating file on server I also check that it does not existing already. However, It is working fine most of the system but one of my client has problem. When he run the application, it throws the system.formatexception i-e input string is not in correct format.

I am unable to understand this problem. Can anybody help me?

The following is the code to create file.

 public string createFile(string filename1)
           {

            StreamWriter sw1 = null;
            System.Net.FtpWebRequest tmpReq1;
            try
            {
            tmpReq1 = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create("ftp://ftp.dunyameri.com/pt/" + filename1);
            tmpReq1.Credentials = new System.Net.NetworkCredential("[email protected]", "xxxxx");
            FtpWebResponse response = (FtpWebResponse)tmpReq1.GetResponse();
            }
            catch (WebException ex)
            {
                FtpWebResponse response2 = (FtpWebResponse)ex.Response;
                if (response2.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
                    {
                        // I am creating file here
                    }
                    else
                    {
                        return ex.ToString();
                    }
            }
            return "File Created";

        }

I haves searched on internet that it might be because of string contain 0 or dots. In this particular system case the file name contain dots and 0. Is it because of this type of file name?

Exception description

Thanks, Naveed

like image 994
Naveed Qamar Avatar asked Dec 05 '25 10:12

Naveed Qamar


1 Answers

It seems that the error does not occur within "createFile(string filename1)". If so, the stack should be similar to this:

...
System.Convert.ToInt32(String value)
e2erta.e2erta1.YourFtpClass.createFile(string filename1) <- I would expect this line!
e2erta.e2erta1..ctor()
like image 107
Hailton Avatar answered Dec 08 '25 00:12

Hailton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!