Click here to Skip to main content
15,867,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could any guide for giving right values LIKE(HOST,USERNAME,PASSWORD)

I am Getting this exception like:SOCKET EXCEPTION CAUGHT

C#
static string host = "ftp://10.10.10.147/C:/";
        static string user="DIPL/SivaRamGopal.v";
        static string password="123456aA";
        static string path = "SubscribersList.csv";
        static List<string> files = new List<string>();
        static string dest_dir = "";
        static bool is_anonymous = false;
        static bool rename_destination = false;
        static bool show_help = false;

        static readonly ILog log = LogManager.GetLogger(typeof(Program));

        static void Main(string[] args)
        {
            using (var db = new Provisioning.Data.ProvisioningWorkUnit())
            {

                
                
                var list = db.FullfillmentServiceTrackLog.Get(x=>x.IsAPI==false);
              
                FileStream stream = new FileStream("SubscribersList.csv", FileMode.Create);

                ExcelWriter writer = new ExcelWriter(stream);
                writer.BeginWrite();

                writer.WriteCell(0, 0, "Msisdn");
                writer.WriteCell(0, 1, "ServiceType");
                writer.WriteCell(0, 2, "DateOfRequest");
                int count = 1;


                foreach (var item in list)
                {
                    writer.WriteCell(count, 0, item.Msisdn);
                    writer.WriteCell(count, 1, item.ServiceType);
                    writer.WriteCell(count, 2, item.CreatedOn.ToString());
                    count++;

                }
                
                writer.EndWrite();
                stream.Close();
                writer = null;
                stream = null;
            }
            try
            {
                FTPClient.FtpClient ftp = new FTPClient.FtpClient(host, user, password);
                Console.WriteLine("Connecting to ftp server {0}", ftp.Server);
                ftp.Login();
                Console.WriteLine("Connnected to ftp server.");
                ftp.Upload(path);
                log.InfoFormat(string.Format("Uploaded successfully"));
                Console.WriteLine("Uploaded to ftp server");

            }
Posted
Updated 22-Dec-12 19:47pm
v2

Since you're using a custom FTPClient library that we know nothing about, it's impossible for anyone to tell you what the problem is.

If you've got that FTPClient library from some vendor, you're best source of information is that vendor.

If you wrote it yourself, we'd need to see the relevent source code for the login method.
 
Share this answer
 
How to: Upload Files with FTP[^]
and have a look at these threads
Catching a Socket Exception in C#[^]
and where is your catch/finally part of the exception handling
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900