Solved

AxInetCtlsObjects.AxInet GetChunk Size Error

Posted on 2008-10-24
4
1,490 Views
Last Modified: 2013-12-20
A couple of years ago I converted a VB6 program to VB.NET. The original used the INET control which in VB.NET became an AxInetCtlsObjects.AxInet object.

The following code executes the SIZE test.txt command and assigns the returned value to MySize.

Dim aInet As AxInetCtlsObjects.AxInet  
Dim MySize as Long  
&&   
aInet.Execute(aInet.URL, SIZE test.txt, "", "")  
MySize = CLng(Trim(aInet.GetChunk(32)))  

If the actual file size of test.txt is less then 4294967296 bytes [=2(32)], MySize gets the correct value. If the file is larger than that, mysize keeps getting 4294967295.

However, when I logon to our FTP site and execute SIZE text.txt command from command prompt directly, it has no problem.

Is this a bug in AxInetCtlsObjects.AxInet or something I missing.

Thanks.
0
Comment
Question by:k9k9kk9
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22803142
It sounds like you can upgrade to using native VB.NET classes, but I would like to understand better what you are trying to do?  Are you working with FTP (that would be an FtpWebRequest.

What version of VB.NET are you using?
0
 

Author Comment

by:k9k9kk9
ID: 22812190
Thank you for taking my question.
 
I didnt use FtpWebRequest. The application was originally written in VB6 and was upgraded to VB.NET. It is a Windows Form app handles file transfer/FTP.  We use  AxInetCtlsObjects.AxInet to execute FTP command and GetChunk command to get results.
 
 
The app involves the following steps:
 
1.      Define the AxInetCtlsObjects.AxInet  object aInet.
Dim aInet As AxInetCtlsObjects.AxInet
With aInet
            .URL = "ftp://" & FTPHost
            .UserName = USRName
            .Password = USRPassword
End With
 
2.      Before a file is transferred, the application checks the files size on the FTP server.
 
           Dim FTPSize as long
            aInet.Execute(aInet.URL, Size test.txt, "", "")
            FTPSize = CLng(Trim(aInet.GetChunk(32)))
           
The problem happens here when a file size is greater than 4294967295(about 4GB). The FTPSize returns 4294967295. I have tried to read the results as string, but it didnt make any difference. Looks like the results from AxInet is 4294967295
 
      Dim a as string
      a = aInet.GetChunk(32).tostring()
 
 
However, if the file size is less than 4294967295, FTPSize returns correct number.
 
 
3.      Get file
     
      Get file
    FTPCmd = Get test.txt 
    aInet.Execute(aInet.URL, FTPCmd, "", "")
           
     This part has NO problem. The file can be transferred to destination.
 
4.      After the transfer, the application checks the file size on the destination local workstation.
 
Dim fi As New System.IO.FileInfo(fileName)
FileSizeLocal = fi.Length
 
      This part works fine. FileSizeLocal is always correct.
 
5.      Make sure the two sizes matches.
 
      If (FileSizeLocal = FTPSize)  then
  &..
  End If
 
      Since the FTPSize is incorrect, the If statement returns false for files larger than 4GB.
 

  Thanks.
 
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 22812349
The COM library doesn't look like it does what you need, so I would suggest taking a different direction.  You might be able to find a solution, by finding some magic, but that is not what I would suggest.  Sometimes, there are just limitations to old technology.  

.NET has a pretty easy way to connect to and work with an FTP server, and that is what I would suggest.  There are plenty of resources available to help you find a way to get what you need.
0
 

Author Comment

by:k9k9kk9
ID: 22814226
I tried FtpWebResponse. It works. Thanks a lot for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to implement Singleton Design Pattern in Java.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now