I'm uploading a zip file from local directory to SFTP using SharpSSH. Everything works fine. However, I would like to get the file size of the current file I just uploaded. The reason I'm doing this is that the zip file is big (from 45 GB to 80 GB) and I want to make sure that during the upload it didn't fail or stuck. Want to make sure the entire zip is uploaded.
I can get the file size of the local zip file like this:
DirectoryInfo di = new DirectoryInfo(yesterdaysArchiveFolder);
FileInfo[] files = di.GetFiles();
foreach (FileInfo f in files)
{
Console.WriteLine("Size of the zip file: " + f.Length);
}
Now, I want to do the same thing for the file I just uploaded to SFTP after the upload is complete.
Since I know the name of the file I just uploaded I create an ArrayList
and put the files from SFTP. I then use for loop
to get the file I just uploaded.
ArrayList FileList = oSftp.GetFileList(_ftpDirectory);
int count = FileList.Count;
Console.WriteLine("Files in SFTP: " + count);
for (int i = 0; i < FileList.Count; i++)
{
if (zipFileName == FileList[i].ToString())
{
Console.WriteLine(FileList[i]);
}
}
The problem is that there're no properties like .Length
to get the file size of that file?
Is there another approach I can take to find out the file size of the file in remote server?