In what format is the response you get? There is no such thing as a text file. There are only binary files. HTTP is also 100% binary.
Text is the interpretation of bytes, and it only exists as part of running application. You can never, ever write text to a file. You can only convert the text to bytes (using various ways) and write the bytes.
Therefore, ask yourself why the bytes you received cannot be interpreted by notepad.exe as text. Maybe the response is not directly text but a ZIP file or something.
- You can guess the format with a hex editor
- You can ask the website owner
In what format is the response you get? There is no such thing as a text file. There are only binary files. HTTP is also 100% binary.
Text is the interpretation of bytes, and it only exists as part of running application. You can never, ever write text to a file. You can only convert the text to bytes (using various ways) and write the bytes.
Therefore, ask yourself why the bytes you received cannot be interpreted by notepad.exe as text. Maybe the response is not directly text but a ZIP file or something.
- You can guess the format with a hex editor
- You can ask the website owner
You don't show in your code sample saving the file anywhere.
But to convert the response to string you can use:
using (HttpWebResponse response = req.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string ResponseTXT = reader.ReadToEnd();
}
Then you can save it with usual techniques http://msdn.microsoft.com/en-us/library/6ka1wd3w%28v=vs.110%29.aspx
Did you mean that?
Converting binary file to text file
linux - How to convert "binary text" to "visible text"? - Stack Overflow
linux - Convert binary mode to text mode and the reverse option - Unix & Linux Stack Exchange
notepad++ handling / converting binary command characters - Stack Overflow
Can you convert binary to text?
What is hello in binary?
What does 01101001 mean?
Videos
I have a code which written in binary type but I want to convert my code into writing the same data into .txt files. Please help me I don’t know how to do this
In the Edit menu of Notepad++ (I'm using v5.9.2) under Paste Special there are actions to Copy, Cut, and Paste Binary Content.

The Notepad++ MIME Tools plugin and Base64 Encode/Decode feature can be used to copy small binary files (typically small jar or zip files) between remote systems using the clipboard.
- Open the Binary file binary1.bin in Notepad++
- Edit -> Select All (Ctrl+A)
- Plugins -> MIME Tools -> Base64 Encode
- Edit -> Select All (Ctrl+A)
- Edit -> Copy (Ctrl+C)
- Edit -> Undo (Ctrl+Z)
- Move focus to a new Notepad++ tab
- Edit -> Paste (Ctrl+v)
- Edit -> Select All (Ctrl+A)
- Plugins -> MIME Tools -> Base64 Decode
- File -> Save As... binary2.bin

od -An -vtx1 Check.tar > Check.txt
You need -v or od will condense sequences of identical bytes.
For the reverse:
LC_ALL=C tr -cd 0-9a-fA-F < Check.txt | xxd -r -p > Check.tar
Or:
perl -ape '$_=pack "(H2)*", @F' Check.txt > Check.tar
If your purpose is to transfer files over a channel that only supports ASCII text, then there are dedicated tools for that like uuencode:
tar cf - myfiles.* | xz | uuencode myfiles.tar.xz | that-channel
And to recover those files on the other end:
uudecode < file.uu
would recreate myfiles.tar.xz.
Or:
uudecode -o - < file.uu | xz -d | tar xf -
To extract the files.
Answering the X part of this XY problem, I would recommend you investigate the reason your binary file transfers don't transfer properly.
If it turns out the reason is because you don't have an 8-bit clean datapath you could then use existing tools that were created to handle this situation, such as base64 or even uuencode. Old but still very effective.
tar czvf - /etc/h* | base64 >/tmp/tar.tgz.b64
ls -l /tmp/tar.tgz.b64
-rw-r--r-- 1 root root 7364 May 26 11:52 /tmp/tar.tgz.b64
...
base64 -d /tmp/tar.tgz.b64 | tar tzvf -
or
tar czvf - /etc/h* | uuencode - >/tmp/tar.tgz.uue
ls -l /tmp/tar.tgz.uue
-rw-r--r-- 1 root root 7530 May 26 11:51 /tmp/tar.tgz.uue
...
uudecode /tmp/tar.tgz.uue | tar xzvf -