Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Here iam storing one zip file in perticular path.
Path is:D:\Tz21-Projects\ImportExport\Export_Trc_Files\Staff_Individual_Data\

so how should i convert this zip path into byte array.
Iam using this code

C#
private byte[] StreamFile(string filename)
   {
       FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

       // Create a byte array of file stream length
       byte[] byteData = new byte[fs.Length];

       //Read block of bytes from stream into the byte array
       fs.Read(byteData, 0, System.Convert.ToInt32(fs.Length));

       //Close the File Stream
       fs.Close();
       return byteData; //return the byte data
   }

But Unfortuanately iam getting the error unable to read the path


Here instead of File name iam sending filepath so please give suggestions regarding this.


Regards,

AnilKumar.D
Posted
Updated 1-May-12 2:16am
v2

1 solution

It is much easier to use File.ReadAllBytes(filename);
 
Share this answer
 
Comments
Anil Honey 206 1-May-12 8:24am    
please can u explain in brief
Anil Honey 206 1-May-12 8:29am    
Could not find a part of the path 'D:\Tz21-Projects\ImportExport\Export_Trc_Files\Staff_Individual_Data\'. iam getting this error in expection
Mehdi Gholam 1-May-12 8:35am    
Make sure your path is correct.

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