Hi, I have a problem here in encoding and decoding of a pdf or docx file.Please find the code below.
string FileName = @"C:\Tips.docx";
FileStream inFile = new FileStream(FileName, FileMode.Open, FileAccess.Read);
binarydata = new byte[inFile.Length];
string Base64String = System.Convert.ToBase64String(binarydata,0,binarydata.Length);
byte[] decoded = System.Convert.FromBase64String(Base64String);
StreamWriter writer = new StreamWriter(@"C:\Tips1.docx", false, System.Text.Encoding.ASCII);
writer.Write(Base64String);
writer.Close();
I am unable to open Tips1.docx file saying File is corrupted.
Can any one tell me whats wrong in the code?