Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public static void UploadToSFTP(List<string> selectedFileList)
        {
                using (var connection = new SQLiteConnection(GeneralFunc.DBFile))
                {
                    List<Model.SFTPSetting> sftpList = new List<Model.SFTPSetting>();
                    string host = "localhost";
                    int port = 22;
                    string username = "gth";
                    string password = "1234";
                    string dir = @"/D/SFTP";
                    using (SftpClient client = new SftpClient(host, port, username, password))
                    {
                        client.Connect();
                        client.ChangeDirectory(dir);
                        foreach (var file in selectedFileList)
                        {
                            using (FileStream fs = new FileStream(testPath + "/" + file, FileMode.Open))
                            {
                                client.BufferSize = 4 * 1024;
                                client.UploadFile(fs, Path.GetFileName(testPath + "/" + file));
                            }
                        }

                    }
                }

it show error on client.Connect();
01-09 11:47:25.081 E/mono    (12159): 
01-09 11:47:25.081 E/mono    (12159): Unhandled Exception:
01-09 11:47:25.081 E/mono    (12159): System.Net.Sockets.SocketException (0x80004005): Connection refused
01-09 11:47:25.081 E/mono    (12159):   at (wrapper dynamic-method) System.Object.5(intptr,intptr,intptr)
01-09 11:47:25.081 E/mono-rt (12159): [ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Sockets.SocketException (0x80004005): Connection refused
01-09 11:47:25.081 E/mono-rt (12159):   at (wrapper dynamic-method) System.Object.5(intptr,intptr,intptr)
01-09 11:47:25.099 E/CameraBase(12159): SCANNING dlclose for instance 0x437bbb5ee79d6b9f
01-09 11:47:25.100 E/CameraBase(12159): SCANNING AFTER DLCLOSE


What I have tried:

i try using cmd and filezilla to connect..it is success connected.
Posted
Comments
David Crow 10-Jan-19 10:13am    
Is this of any help?

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