Solved

AxInetCtlsObjects.AxInet GetChunk Size Error

Posted on 2008-10-24
4
1,486 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 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

10 Experts available now in Live!

Get 1:1 Help Now