This project is read-only.

Trying to Upload Multiple Files and ChannelNumber error

Feb 20, 2012 at 1:27 AM

I am able to upload 1 file with no problem, the issue is when I try to upload multiple files, I get an error.  What can I do to solve this issue?  I basically create one method for each file and repeat the method for each file to be uploaded. 


After trying to upload both files, I get the eror that states:


NullReferenceException was Unhandled

Object Reference not set to an instance of an object.


Below is my code for the method to upload the files:

private void CelegroUploadIncFile(string hnameincfile, string huseridincfile, string hpasswordincfile, int hportincfile, string fnameincfile, string fpathandnameincfile, string ftagnameincfile)
            string hnameforincfile = hnameincfile;
            string huseridforincfile = huseridincfile;
            string hpasswordforincfile = hpasswordincfile;
            int hportforincfile = hportincfile;
            string fnameforincfile = fnameincfile;
            string fpathnameincfile = fpathandnameincfile;
            string ftagincfile = ftagnameincfile;

            using (var sftp = new SftpClient(hnameforincfile, hportforincfile, huseridforincfile, hpasswordforincfile))

                bool IncFile;

                using (System.IO.Stream stream = new System.IO.FileStream(fpathnameincfile, FileMode.Open))
                    FileInfo FInfo = new FileInfo(fpathnameincfile);
                    long sizeoffile = FInfo.Length;

                    if (sizeoffile < 1)
                        IncFile = false;
                            sftp.UploadFile(stream, ftagincfile, true);
                            IncFile = true;
                            //  sftp.EndUploadFile();
                        catch (InvalidCastException e)
                            throw (e);
Feb 21, 2012 at 2:06 PM



I would need to know a little bit more about this error.

Where exactly it occurs? Does it say what line ?