Search Postgresql Archives

Read problem from Bytea column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I have postgresql 8.3.9 database. Now I am working on reading file
from bytea data and save to filesystem.
I am using Npgsql.dll on c#.net.

First I have using OpenERP to upload a file to postgres database in
bytea column. The original file size is 104,960 bytes and .doc
extension.
Then I read the bytea data and save it to file system, its size
becomes 141,790 bytes. This file cannot be opened however its
extension is .doc.

What is going on?

My c# code is below:

             NpgsqlCommand cmd = new NpgsqlCommand("SELECT bytea_col
FROM TableTest LIMIT 1", Conn);
             using (FileStream stream = new FileStream("c:\test.doc",
FileMode.Create))
                    {
                        byte[] rawbytes = (byte[])cmd.ExecuteScalar();
                        stream.Write(rawbytes, 0, rawbytes.Length);
                        stream.Close();
                    }

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux