FileStream fls = new FileStream(@filepath, FileMode.OpenOrCreate, FileAccess.Read); byte[] blob = new byte[fls.Length]; fls.Read(blob, 0, System.Convert.ToInt32(fls.Length)); fls.Close(); string query = "update employee set doc = :BlobParameter "; OracleParameter blobParameter = new OracleParameter(); blobParameter.OracleType = OracleType.Blob; blobParameter.ParameterName = "BlobParameter"; blobParameter.Value = blob; OracleCommand cmd = new OracleCommand(query,conn); cmd.Parameters.Add(blobParameter); cmd.ExecuteNonQuery(); conn.Close(); conn.Dispose(); }
string sql = "Select doc from employee where docId = '121'"; OracleCommand cmd = new OracleCommand(sql, conn); OracleDataReader dataReader = cmd.ExecuteReader(); dataReader.Read(); OracleLob blob = dataReader.GetOracleLob(0); dataReader.Close(); // Create a byte array byte[] byteData = new byte[0]; // fetch the value of Oracle parameter into the byte array byteData = (byte[])blob.Value; // get the length of the byte array int ArraySize = byteData.GetUpperBound(0); // Write the Blob data fetched from database to the filesystem at the destination FileStream fs1 = new FileStream(FilePath, FileMode.OpenOrCreate , FileAccess.Write); fs1.Write(byteData, 0, ArraySize); fs1.Close();
byte[] data = File.ReadAllBytes(path); ... File.WriteAllBytes(path, data);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)