OracleConnection objOcon=new OracleConnection("user id=system;data source=user;password=pass");
OracleCommand objOcmd = new OracleCommand("select sopinstanceuid,dicomimage from images where
getdate is not null", objOcon);
FileStream fs;
BinaryWriter bw;
int bufferSize = 30; //方
byte[] outbyte = new byte[bufferSize];
long retval;
long startIndex = 0;
string pub_id = "";
pubsConn.Open();
OracleDataReader myReader = logoCMD.ExecuteReader(CommandBehavior.SequentialAccess);
while (myReader.Read())
{
pub_id = myReader.GetString(0);
fs = new FileStream("c:\\dicomimage\\" +pub_id + ".dcm", FileMode.OpenOrCreate,
FileAccess.Write);
bw = new BinaryWriter(fs);
startIndex = 0;
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
while (retval == bufferSize)
{
bw.Write(outbyte);
bw.Flush();
startIndex += bufferSize;
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
}
if (retval>0)
{
bw.Write(outbyte, 0, (int)retval - 1);
}
bw.Flush();
bw.Close();
fs.Close();
}
myReader.Close();
pubsConn.Close();