Click here to Skip to main content
11,495,493 members (65,524 online)
Rate this: bad
Please Sign up or sign in to vote.
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 29-Jun-11 0:21am
Edited 29-Jun-11 0:23am
Parwej Ahamad at 29-Jun-11 5:46am
Have you read this discussion:
phil.o at 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 ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

System.Text.Encoding enc = System.Text.Encoding.ASCII;
string myString = enc.GetString(myByteArray )
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Try with the

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

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

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 29 Jun 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100