Home Forums .NET libraries Xceed SFTP/FTP for .NET Remote File Size

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20696 |

    Hello everyone,

    Is there a way to know the file size in bytes of a file on the server. Can I assign FtpItemInfo to a specific file to get its information, is there a way in which GetFolderContents is not used.

    Thank you

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by akramg (had 2404 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    The best way is to use GetFolderContents (note fileName is not the full path to the folder and it is assumes that the current working directory of the FTP connection is where the file is located):

    Private Function GetRemoteFileSize(ByVal fileName As String) As Long

    Dim result As IAsyncResult
    Dim file As Xceed.Ftp.FtpItemInfo
    Dim files As Xceed.Ftp.FtpItemInfoList
    Dim returnValue As FTPFileInfo

    result = ftpConnection.BeginGetFolderContents(fileName, Nothing, Nothing)

    Do While Not result.IsCompleted
    Application.DoEvents()
    Loop

    files = ftpConnection.EndGetFolderContents(result)

    If files.Count = 0 Then
    Return -1
    Else
    return files(0).Size
    End If

    End Function

    Regards,

    Kris Sheglova

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Kris (had 3377 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.