Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more: (untagged)
i am using copy /b command to append two diff files in one file. the problem i am experiencing is that this command is not working if the first file is of size larger than 1 gb. i experienced it by myself and i am not finding any references or help from net about this. but this is what happening, i am using command like this

copy /b file1+file2 outputfile

if file1 is greater than 1gb , the command says 1 files copied but file is not copied. i searched alot but no one has stuck in this issue before plz i need help about this issue, how to solve it or is there any software or something that can do the same work but on larger files. if any1 need some other info to answer this question plz feel free to ask Regards
Posted
Updated 28-Jun-13 8:19am
v2
Comments
Zoltán Zörgő 28-Jun-13 14:26pm    
Might happen. Copy is coming from the really old command.com internal command set. I can imagine, there is a variable in the code that the guys from Microsoft have forgotten to "update" to some 64 bit one. You might have found a bug. I suggest you report to them.
But my question is? Can't you use something else?
hinaheed 29-Jun-13 1:00am    
Yes i can use something else and I will be glad to switch to that, but only if i knew something. if you know any alternative for doing the same action kindly share. :)
Zoltán Zörgő 29-Jun-13 1:39am    
Well, since this is a programming forum, I suggest you make your own code.
In c# you can start here: http://stackoverflow.com/questions/3556755/how-to-merge-efficiently-gigantic-files-with-c-sharp
If you don't want to use .net and compile code, just use vbs: http://code.huypv.net/2013/05/vbs-merge-binary-files.html
You could even use PowerShell: http://stackoverflow.com/questions/1783554/fast-and-simple-binary-concatenate-files-in-powershell
hinaheed 29-Jun-13 2:04am    
actually yes i have embedded this command into my c# application and that will be more appropriat if direct coding is done instead. first link seems to be helpful to me. I'll share my results after trying that. Thnkx, Regards and stay blessed :)
hinaheed 29-Jun-13 3:04am    
I tried this code :

private void button1_Click(object sender, EventArgs e)
{
// then use as follows (do in a loop, don't forget to use using-blocks)
Stream yourInputStream = new System.IO.FileStream("C:\\test\\zip.zip", FileMode.Open);
Stream yourOutputStream = new System.IO.FileStream("C:\\test\\test.mp4", FileMode.Append);

CopyStreamToStream(yourOutputStream, yourInputStream);

}


void CopyStreamToStream(Stream dest, Stream src)
{
int bytesRead;

// experiment with the best buffer size, often 65536 is very performant
byte[] buffer = new byte[999999];

// copy everything
while((bytesRead = src.Read(buffer, 0, buffer.Length)) > 0)
{
dest.Write(buffer, 0, bytesRead);
}
}


exactly doing the same work as copy /b command, but same issue is also here. if the output file is greater than 1 gb i cant open it using winrar to view the embedded file as i can view in the file less than 1 GB. I think, the problem is not with copy /b command or this code. because filesize increases exactly with proportion, so problem may be during opening files with winrar. Seems that i can embed file but cant extract it later :( Im stuck

I think you are doing something wrong: I just tried it by copying a 1.01GB file into a "spare" folder twice and renaming them to file1 and file2.
Then in a command prompt I changed to the appropriate folder, and entered:
copy /b file1+file2 outputfile
It took a little time, but it worked fine and I ended up with two 1.01GB files, and 1 2.02GB file.

So what am I doing that is different from you?
 
Share this answer
 
You are correct for what you are saying.. yes, ofcourse the file size increases in the proper manner. my actual problem is that I am trying to embed a zip folder with some files in it and trying to append it with a file( which is more than 1gb).
like : copy /b file1(large file)+zipfile outputfile
if file1 is less than 1 gb, I can open outputfile using winrar and can view the files that was previously in the zip folder.
but, in case if file1 is greater than 1GB, if i choose to open outputfile using winrar it prompts that "No archives found". thats my major problem.
 
Share this answer
 
Well.. I figured out that the problem I was thinking wasn't even the problem. no problem with copy /b command, no limit issues. It was winrar. So I figured out to work without using winrar. Thankx for replies :)
Kind Regards
 
Share this answer
 
Comments
Zoltán Zörgő 29-Jun-13 11:32am    
Than you have not shared with us a really important aspect.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900