Word count for the uploaded file

Thread is closed for posting
2 posts, 0 answers
  1. Van
    Van avatar
    1 posts
    Member since:
    Oct 2011

    Posted 13 Oct 2011 Link to this post

    Hello,
    Is it possible to find the word/char/page count of the uploaded file?

    Thanks and Regards,
    VanDaniel
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Jan 2013 Link to this post

    Hi,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadUpload ID="RadUpload1" runat="server">
    </telerik:RadUpload>
    <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />

    C#:
    protected void Button2_Click(object sender, EventArgs e)
    {
        UploadedFile file = RadUpload1.UploadedFiles[0];
        StreamReader reader = new StreamReader(file.InputStream);
        string s = reader.ReadToEnd();
        MatchCollection collection = Regex.Matches(s, @"[\S]+");
        Response.Write(collection.Count);
    }

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top