Hi,
Is there any way to convert a file in to text data or text file?
How to convert a file into text data?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Selva GanapathyRank #560 · 4.3K reputationPosted Mar 12, 2014, 8:47 PM EDT
Seems you are trying to convert a file into a text data. If so please using the following code to meet your requirement.
private void button1_Click(object sender, EventArgs e)
{
var bytes = File.ReadAllBytes("../../thiruvalluvar.jpg");
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Text.txt")) // Open a text file to extract
{
foreach (var item in bytes)
{
file.Write(item.ToString());
}
}
System.Diagnostics.Process.Start("Text.txt");
}
output:
Regards,
Selva Ganapathy K
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Mar 10, 2014, 9:18 PM EDT
nathaJegamoorty Pillai84 reputationPosted Mar 12, 2014, 9:49 PM EDT
Perfect.. Thanks..