If Gremmy said it copies large files, the I believe that something is flawed on your end. I did a quick search, and found this thread (kind of old, but might be fitting?)
http://www.msfn.org/board/copy2gb-t81200.html
Printable View
If Gremmy said it copies large files, the I believe that something is flawed on your end. I did a quick search, and found this thread (kind of old, but might be fitting?)
http://www.msfn.org/board/copy2gb-t81200.html
Gremmy said it can handle large files, he never said it can copy large files. Simply because the routine wasn't made to do that. I need to develop that routine. Furthermore, I can't try his program since it fails before I can use it, as posted in my previous post.
Your post is interesting, but I believe it relates to the operating system directly. My OS can copy large files, but my VB6 program can't. I need to know how to do it in VB6. I want a status bar so I can't use the FileSystemObject method of copying files, besides on a 2+ gig file it would appear to have locked....not what I want.
Knight.
Your code looks quite good and should work with a little modification.
The EOF() function expects a VB filenumber, but you give it the filehandle hFileSource you received from the API call to CreateFile(). This is not a valid VB filenumber, so you cannot use the EOF() function here.
Either there is an API GetEndOffile(hFileHandle) you can use (I don't know, didn't look it up), or you simply determine the file's end through your counting down from the filesize. If it reaches zero (or underruns zero) the last chunk is reached.
I've not been around much lately .. Between the Job and my 4th grandchilds birth last week, I've been batteling to keep up ... how ever i did get your msg, Knightofoldcode...
You will have to write a special function to take care of the copy ... The Module handles the file open, read, write and close. You need to handle the bits between the read and write...Quote:
Gremmy,
I've read one of your posts about breaking the 2 gb limit, and I've read your tutorial. However, I'm still confused as to how to copy a file larger then 2 gb. I tried reposting on the same thread, however no one else was helping, just telling me to go through debug tools and look at previous code. I've looked at previous code.. to that end I downloaded your hex editor code, however it fails when I try to use it, on the line:
API_OpenFile Tmp_File, File_Num, File_Len
inside the File -> Open menu code.
Please help me figure out how to create a subroutine to simply copy a large 2gb+ file from one place to another!
Much MUCH thanks,
Knightofoldcode.
Psudo code (Using the Functions from the article module)The Above sub is a very good start on how to do a copy for files over 2 gig..Code:Public Sub API_CopyFile (Source as string, Dest as String)
Dim FileSize as currency
Dim FileWSize as currency
Dim Pos as Currency
Dim FreadNum as integer
Dim FwrteNum as integer
Dim Block() as byte
Dim BlockSize as integer
Dim Blockread as integer
'Set Block size according to personal pref.
blocksize = 2048 ' 2K
redim Block(blocksize)
API_Openfile (source, FreadNum, Filesize)
API_Openfile (Dest, FwrteNum, FileWsize)
If FileWsize>0 then
'Dest has data .. lets clear it
API_SetEndOfFile (FwrteNum,0)
End If
pos = 0
while Pos < FileSize
Blockread = BlockSize
API_ReadFile(FReadNum, Pos, Blockread, Block)
API_WriteFile(FWrteNum, Pos, Blockread, Block)
Pos = Pos + Blockread
'show whatever progress you want here ..
Wend
API_CloseFile(FreadNum)
API_CloseFile(FwrteNum)
End Sub
I've looked over the code you posted and it is almost the same way that Windows copies files, and 'WILL NOT' work with 2Gig or larger files..
If you took carefull notice in the article the third para' describes why .. Long's have a MAX value of 2,147,483,647 (2gig), and your code uses only one of the two longs for size, limiting you to 4gig if you managed to get it to work. The Module uses the Currency type for the file size and position variables, these now have a max of ~970gig, far exceeding any std hard drive size.... and has some nifty code to convert the currency to the two longs needed for the API's...
hope this helps ...
Gremmy.....
Gremmy,
I appreciate your help, and wasn't trying to be rude to anyone. All help is appreciated.
I think I was getting confused on the very many different ways of doing it. I've got easily 10 subroutines that all either didn't work properly, or didn't copy above 2 gig files.
I don't know how many times I've read your tutorial, yet still never been able to understand how to use the module.
Again, thank you, all.
Gremmy, doesn't the subroutine have to tell it where to advance the pointer? I thought I read somewhere that I'd need to advance the pointer since that method doesn't do it for you? I haven't checked the posted code yet, I guess I should do that.... ;)
Knight.
oops ... you are right ... i did leave out code to advance the pointer.. ( i fixed it in the code above ) .. the line Pos = Pos + BlockRead ... slight over sight when typing in the psudo code .. also posibly tiredness ...
API usage is slightly advanced and this module does take it a little over the top .... the thing is, once you understand API's, its easier to understand how the module works...
also i'm not sure as to why the Hex Editor does not want to run for you but i suspect that it could be that its trying t o pass a Long instead of currency type to the Sub.....
Gremmy..
GremlinSA or any other member,
I apologize for constantly bringing back up this dead thread... But I am still having problems getting large files to copy, for that matter, to generate md5sums for large files also.
I keep getting soo discouraged that I give up, then the project that I'm working on needs to be done, so I give it another go...
Using the most recent code posted, I get error of
"ByRef argument type mismatch"
It highlights the line: Call API_OpenFile(Source, FreadNum, FileSize)
And in particular it highlights the "FreadNum" of that line.
When I download the hex editor example, and click, "open" I get a error of the same type!
Is there anyway I can get a little more help? I've tried everything I can think of, and nothing gets me further, otherwise I'd be willing to post what I've done, but nothing is helping....
Knight.
Sir Knight of the old code, how are you calculating the MD5 hash? Are you using the API or using something you found over at PSC?
As for other large file reading/writing, please see this thread... http://www.vbforums.com/showthread.php?t=531321
Good Luck
You better show more code. How is API_OpenFile() declared? What data types are the variables you pass to it?
Hi,
To read the large files size (more than 2Gb) in VB6 I use the following way:
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set fi = fs.GetFile(CStr(FileName))
FileSize = fi.Size
then I open file:
hFile= FreeFile
Open FileName For Binary As hFile
last, it is required to read a chunk string with given BlockSize and from some Position of this large file.
So I would appreciate if you help me with this API. I.e. inside for the following function:
strCurr$=GetDataStringFromPosition (hFile, Position, BlockSize)
Thanks in advance for your help and prompt response.
Read every post, starting from page #1. If that doesn't answer your question, then START A NEW THREAD.