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

Posted on 2006-05-05
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
    LVL 9

    Accepted Solution

    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

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now