Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
1.75/5 (4 votes)
See more:
hi friends,

what mean this code?

MIDL
byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);

byte[] fileData = File.ReadAllBytes(filePath + fileName);

byte[] Data = new byte[4 + fileNameByte.Length + fileData.Length];

byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);

fileNameLen.CopyTo(Data, 0);
fileNameByte.CopyTo(Data, 4);
fileData.CopyTo(Data, 4 + fileNameByte.Length);


specifically this code

MIDL
fileNameLen.CopyTo(Data, 0);
           fileNameByte.CopyTo(Data, 4);
           fileData.CopyTo(Data, 4 + fileNameByte.Length);


thank you
Posted
Comments
Sergey Alexandrovich Kryukov 12-Jun-11 14:32pm    
Why not take a look at help page? Every line is explained. Sorry, my 1.
--SA
[no name] 12-Jun-11 19:21pm    
CP'S netiquette: "Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.. "
Seems not to be a addressed to SAKryuko....
parmar_punit 13-Jun-11 5:57am    
I agree, we are here to share the knowledge, not to insult other.
Sergey Alexandrovich Kryukov 18-Jun-11 1:45am    
What do you consider insulting? My vote of 1? Please...
By the way, account of xxxxxxxy is now disabled. Guess why?
--SA

File name and the file content is encoded together in 1 array of bytes, array Data
 
Share this answer
 
Comments
guendouz bachir 12-Jun-11 12:39pm    
This code please
=====================
fileNameLen.CopyTo(Data, 0);
fileNameByte.CopyTo(Data, 4);
fileData.CopyTo(Data, 4 + fileNameByte.Length);
Sergey Alexandrovich Kryukov 12-Jun-11 14:34pm    
Better accept both answers formally. You already gave code. By the way, how come you present the code you don't understand? You're suppose to write code instead, as this resource if for developers :-)
--SA
Sergey Alexandrovich Kryukov 12-Jun-11 14:32pm    
Sure, my 5.
--SA
Kim Togo 13-Jun-11 1:34am    
Thanks SA
parmar_punit 13-Jun-11 5:55am    
:) My 5
Take a look at Array.CopyTo Method (Array, Int32)[^] MSDN.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Jun-11 14:33pm    
My 5.
--SA
Wonde Tadesse 6-Dec-11 10:59am    
Thanks
guendouz bachir 12-Jun-11 18:20pm    
thank you Wonde Tadesse
Wonde Tadesse 12-Jun-11 18:35pm    
You're most welcome
Kim Togo 13-Jun-11 1:35am    
My 5. Just what OP wants.

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