The function is called getBinaryFile, but then you pass back an array of
bytes?
I'm not sure that PDF's are stored in blocks of 8-bit characters. If they're
not, then this would definately not work.
CVS, XML and HTML files are all just text files, even though these can still
be in a unicode format which means that every other byte in the array you
pass back would be null. I'm not sure how this would affect the files if you
were to write them back out as ASCII files again.
Normally in this sort of scenario, the files are stored to disk as they are,
and then linked from the database. This also saves a tremendous about of
space in the database.
Hope that helps.
Daniel.
"AlanS" <Al***@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
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?