如何在Windows C#中获取文件的文件? [英] How Do I Get Filebytes Of A File In Windows C#?
本文介绍了如何在Windows C#中获取文件的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button1_Click(object sender, EventArgs e)
{
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
string filename = openFileDialog1.FileName;
int len= openFileDialog1.FileName.Length;
}
}
在这里,我得到了文件的长度但是,实际上我想要byte [] ....中的文件的文件字节来将它与存储在二进制数据(图像数据类型)中的数据库文件进行比较。
plz帮助...... :)
提前谢谢...... :)
Here, i am getting the length of a file but, infact i want filebytes of a file in byte[]....to compare it with the database file which is stored in binary data (image data type).
plz help...:)
thanks in advance...:)
推荐答案
使用File.ReadAllBytes()
:
UseFile.ReadAllBytes()
:
byte[] b = File.ReadAllBytes(filename);
Bitmap bmp = new Bitmap(image);
FileStream fs = new FileStream(image, FileMode.Open, FileAccess.Read);
byte[] bimage = new byte[fs.Length];
另一种方式
another way
这篇关于如何在Windows C#中获取文件的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文