This is a migrated thread and some comments may be shown as answers.

Word count for the uploaded file

1 Answer 58 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Van
Top achievements
Rank 1
Van asked on 13 Oct 2011, 04:24 PM
Hello,
Is it possible to find the word/char/page count of the uploaded file?

Thanks and Regards,
VanDaniel

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jan 2013, 09:55 AM
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.
Tags
Upload (Obsolete)
Asked by
Van
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or