如何将Zip文件路径转换为Byte Arry [英] How to convert Zip file path in to Byte Arry

查看:161
本文介绍了如何将Zip文件路径转换为Byte Arry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我在这里在垂直路径中存储了一个zip文件.
路径为:D:\ Tz21-Projects \ ImportExport \ Export_Trc_Files \ Staff_Individual_Data \

所以我应该如何将这个zip路径转换为字节数组.
我使用此代码

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

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
   }


但是不幸的是,我遇到了无法读取路径的错误


在这里,而不是通过文件名iam发送文件路径,因此请提供有关此问题的建议.


问候,

AnilKumar.D


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

推荐答案

使用File.ReadAllBytes(filename);


这篇关于如何将Zip文件路径转换为Byte Arry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆