I have uploaded a html file using FileUpload control and want to extract string from it

Posted on 2006-05-05
Medium Priority
Last Modified: 2010-08-05
System.IO.Stream s = FileUpload1.PostedFile.InputStream;

I have uploaded a html file using FileUpload control and want to extract string from it
what is the simplest way to do this?
Question by:joshuadavidlee
1 Comment

Accepted Solution

pallosp earned 2000 total points
ID: 16620414
using (Stream s = FileUpload1.PostedFile.InputStream) {
    byte[] buf = new byte[FileUpload1.PostedFile.ContentLength];
    s.Read(buf, 0, buf.Length);
    Console.WriteLine(new System.Text.ASCIIEncoding().GetString(buf));

You may convert it to different encoding depending on the content.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question