0

I'm reading the .CSV files using ftp path { ex:(ftp://IPAddress/Price/Live/) } with username and password credentials. (I'm passing in parameters)

when I enable "request.EnableSsl = true;". I'm getting this error:"The remote certificate is invalid according to the validation procedure"

I'm not sure where I did the mistake to enable the enableSsl connection.

This is what I used the method to connect to "FTP" to access the directories and files.

Hot to resolve this without error.

   private static List<string> getfileList(string wurl, string wuid, string wpwd, string Ext)
        {
            List<string> directories = new List<string>();

            try
            {
                
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(wurl);
                request.Credentials = new NetworkCredential(wuid, wpwd);
                request.EnableSsl = true;
                request.Method = WebRequestMethods.Ftp.ListDirectory;

                StreamReader streamReader = new StreamReader(request.GetResponse().GetResponseStream());
                string fileName3 = streamReader.ReadLine();

                while (fileName3 != null)
                {
                    if (Ext == "F")
                    {
                        if (Path.GetExtension(fileName3).Equals(".csv", StringComparison.InvariantCultureIgnoreCase))
                        {
                            directories.Add(fileName3);
                            fileName3 = streamReader.ReadLine();
                        }
                    }
                    else if (Ext == "D")
                    {
                        directories.Add(fileName3);
                        fileName3 = streamReader.ReadLine();
                    }
                }

                streamReader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not read File..." + ex.Message.ToString()); ;
            }

            return directories;
        }

(sorry for my bad English) I'm new to coding....

Help me from this with your best solution.

Ashok
  • 25
  • 4

0 Answers0