Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ContentLength not available from server
Message
From
17/03/2010 06:21:50
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
ContentLength not available from server
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01455028
Message ID:
01455028
Views:
88
By looking at this code, does anyone know why the ContentLength returns -1 for the file that I am trying to download from a FTP server? The file exists. But, this code returns -1 for lnContentLength.
            Dim lcURI As String = ""
            Dim lnContentLength As Integer = 0
            Dim loFtpWebRequest As System.Net.FtpWebRequest = Nothing
            Dim loFtpWebResponse As System.Net.FtpWebResponse = Nothing

                ' URI
                lcURI = "ftp://" + cHost + "/" + cRemoteDirectory + "/" + cRemoteFile

                ' FTP setup
                loFtpWebRequest = System.Net.FtpWebRequest.Create(New Uri(lcURI))
                loFtpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
                loFtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
                loFtpWebRequest.UseBinary = True

                loFtpWebResponse = loFtpWebRequest.GetResponse()

                ' Get the length
                lnContentLength = loFtpWebResponse.ContentLength
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform