Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 14th, 2005, 09:55 PM
bandoola bandoola is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 3 bandoola User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 sec
Reputation Power: 0
check file corruption

Is there a way for vb to check if a file is corrupt?

The problem i m facing is that some files i downloaded by my ftp program is corrupt. I would like to add some codes to check whether the downloaded files are corrupt.

Thanks in advance

Reply With Quote
  #2  
Old June 15th, 2005, 08:49 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 5
Quote:
Originally Posted by bandoola
Is there a way for vb to check if a file is corrupt?

The problem i m facing is that some files i downloaded by my ftp program is corrupt. I would like to add some codes to check whether the downloaded files are corrupt.

Thanks in advance


Some years ago (20 years...) my brother give me some disks without files and said that there where some huge files (huge in it's time) with a database and wanted it to be recovered. I tried a norton unerase utility but without success, so I make a file with all the disk area and a program to filter out garbage.

The trick is you can compare the data with a pattern that you have (symbols, dates, even that a date is greater than other in the row). This aproach work fine with ascii files and the file I am talking about was done with btree (and ratter old DB and mostly ASCII).

There are other aproaches, but the easyest could be to obtain a checksum byte that represent all the file, you can add each ascii value (65=A...) to a single value that represent all the characters on the file and if the checksum value is OK the file is OK. Some guys do it in a byte or two byte value so if the value is bigger than the maximum, no problema just obtain the range taking off the max value.

Code:
Private Sub Command1_Click()
Dim j As Byte, k As Long, i As Byte
 TXT = "Hi there, it has been a pleasure to talk about"
 j = 0
 For i = 1 To Len(TXT)
   k = Asc(Mid(TXT, i, 1))
   If j + k > 255 Then  j = j + k - 255   Else  j = j + k
 Next i
MsgBox j
End Sub

"Hi there, it has been a pleasure to talk about" = 68

The procedure can be applied even with each character readed from a file in a binary (non ascii) file.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > check file corruption


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT