Best way to make a file coder?

Hello,

I am going to make a file coder in Visual Basic and I have some questions.
This program will be used to code files up to 4GB filesize and I don't know what would be the best way.

Since Visual Basic is not my best, I've started with a little program which copies the file byte to byte (in next versions, that byte should be coded). But doing it byte to byte it is too slow. Even doing it with strings of 16 bytes it could take up to 2 hours to code a 4GB file. I've tried to do strings of 1000 bytes but when I code around 2GB I get "runtime error 63, registry number incorrect".

Moreover, when I added a progress bar, the program got 5 times slower.

Is this normal? or can anyone give me a tip to make this better? maybe does it get faster in C?
Comments, opinions and help please :)

PS: source and destination files are opened "as binary", is it ok?
TxEdOAsked:
Who is Participating?
 
moduloConnect With a Mentor Commented:
PAQed with points refunded (125)

modulo
Community Support Moderator
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Define 'File coder'.
0
 
2AngelCommented:
Hi,
First, you must know that handle a BIG file is matter of the "machin" (Memory capacity and Proccessor speed).
Second, can you paste the code? How do you "open" the file for binary editing?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
TxEdOAuthor Commented:
File coder (in my case): a program to encrypt a file, this file won't be understandable for other programs but the 'file decoder'. For example, I code a JPEG image, and a image viewer won't show the image, you should use the 'file decoder' to decode it, then view it with the image viewer.

The code for opening the file for binary editing:
    Dim str1 As String * 1000 'A number of bytes
    'Dim str2 As String * 1000
    Open source For Binary As #1
    Open destine For Binary As #2
    Do Until EOF(1)
        Get 1, , str1
        'str2 = coding_algorithm(str1)
        Put 2, , str2
    Loop
    Close #1
    Close #2

As I said, if I add a progress bar, it gets like 5 times slower :(
Any idea?
0
 
wraith821Commented:
here is an idea... get winzip. use the command line utility, just zip the file with a password and rename it to .dat, maybe the users wont realize what the file is, then you can unzip it when you need to. you could also update the zip file when changes have been made to the file by replacing the file inside the zip file with the new one. might be a little clunky but it would be alot faster.

for the way your doin it...
most people dont have 4gb of memory to put the whole file in so your going to have to do it in chunks. also your chunks need to be 16,32,64,128,256,512,1024,... just to be on the safe side.
0
 
TxEdOAuthor Commented:
Using winzip is not acceptable for what i need.
I need to make a complete file coder, the objective of this, is to get a unique password for each user.
0
 
2AngelCommented:

Hi,

First, try to understand where the problem is. Try to separate the process. Try to open one file and to write it to another file without the encryption. If this process is working fine the try to see where is the problem with the encryption (I don't have the code…).

Second, I don't know for sure, but I think the way you open the file is not the way it should be. Take a look at the links blow:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmopen.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingbinaryfileaccess.asp

http://www.developerfusion.com/show/37/8/

Good luck!
0
 
2AngelCommented:
Hi,

As you can see I made my best to help and I think I did... but no comment from him...

Tks.
0
 
TxEdOAuthor Commented:
I haven't accepted any comment since my problem wasn't solved.

I still get the runtime error when the file size is more than 2 GB.

By the way, sorry for being too late but I was on a travel :)
0
 
2AngelCommented:
Hi,
Btw, did you to run it on another system? Maybe your system can't handle the file?

Regards.
0
 
TxEdOAuthor Commented:
I don't think its a system problem since I have a p4 2.4@800, 512 DDR400

When the filesize is lower than 2 GB the program works fine, but it crashes when its larger than 2 GB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.