Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
1.17/5 (4 votes)
we insert the word files in database in varbinary format.
Now we want to retrieve the word files then we are converting the varbinary format to string.

Here we are using the code:-
string x = Encoding.ASCII.GetString(buffer).ToLower();

It is working for .doc files only.
when we retrieve the .docx file it can't convert to string and result is not getting.
How can we convert .docx file as byte to string format when we are retrieving
string str1 = System.Text.ASCIIEncoding.ASCII.GetString(value).

Iam trying with the above code
It is not working.
Posted
Updated 16-Sep-19 9:05am
v2
Comments
Parwej Ahamad 29-Jun-11 5:46am    
Have you read this discussion: http://stackoverflow.com/questions/2259037/upload-download-file-from-sql-server-2005-2008-from-winforms-c-app
phil.o 29-Jun-11 6:14am    
What is the error returned when you try to convert back your .docx file ?
Are you sure ASCII encoding is the most relevant ? Does it give a different result with Encoding.UTF8 for instance ?

C#
System.Text.Encoding enc = System.Text.Encoding.ASCII;
string myString = enc.GetString(myByteArray )
 
Share this answer
 
Try with the

byte [] dBytes = string str;
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
str = enc.GetString(dBytes);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900