Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# FTP
Could any guide for giving right values LIKE(HOST,USERNAME,PASSWORD)
 
I am Getting this exception like:SOCKET EXCEPTION CAUGHT

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 22-Dec-12 19:45pm
Edited 22-Dec-12 19:47pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 CPallini 375
1 Sergey Alexandrovich Kryukov 370
2 BillWoodruff 314
3 George Jonsson 279
4 OriginalGriff 217
0 OriginalGriff 5,030
1 CPallini 4,115
2 Sergey Alexandrovich Kryukov 3,554
3 George Jonsson 2,826
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100