if (openFileDialog1.FileName != null)
{
v_Filepath = FilePath;
System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fs);
long byteLength = new System.IO.FileInfo(FilePath).Length;
Attachmnt = binaryReader.ReadBytes((Int32)byteLength);
fs.Close();
fs.Dispose();
binaryReader.Close();
}
string newName;
newName = saveFileDialog1.FileName;
File.WriteAllBytes(saveFileDialog1.FileName, objDoc.DocContent);
writeStream = new FileStream(saveFileDialog1.FileName, FileMode.Open);
BinaryWriter writeBinay = new BinaryWriter(writeStream);
writeBinay.Write(objDoc.DocContent);
writeBinay.Close();
writeStream.Close();
or check my Question link:-
how to save a byte[] code in pdf/rtf/xps/doc file.(Windows not asp)[
^]