G
Guest
I am reaing files of different format (PDF, XLS, CVS, XML, HTML). I will take
the output and store in in an image field in a database table. The following
is the code I am using to read the files.
public byte[] getBinaryFile(string pOutputPath)
{
FileInfo fi = new FileInfo(pOutputPath);
byte[] fileData = new byte[fi.Length];
FileStream fs = new FileStream(pOutputPath, FileMode.Open, FileAccess.Read);
BinaryReader bfs = new BinaryReader(fs);
bfs.Read(fileData, 0, (int)(fi.Length));
bfs.Close();
fs.Close();
return fileData;
}
This code seems to work for all file formats except PDF. It seems to corrupt
the PDF files. What should I be doing to handle PDF files?
the output and store in in an image field in a database table. The following
is the code I am using to read the files.
public byte[] getBinaryFile(string pOutputPath)
{
FileInfo fi = new FileInfo(pOutputPath);
byte[] fileData = new byte[fi.Length];
FileStream fs = new FileStream(pOutputPath, FileMode.Open, FileAccess.Read);
BinaryReader bfs = new BinaryReader(fs);
bfs.Read(fileData, 0, (int)(fi.Length));
bfs.Close();
fs.Close();
return fileData;
}
This code seems to work for all file formats except PDF. It seems to corrupt
the PDF files. What should I be doing to handle PDF files?