473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

StreamReader to read word file-(output-Strange Characters)

16
I am trying to read a word file and display it in a panel.
my idea is like below,which is not providing correct output:

Expand|Select|Wrap|Line Numbers
  1. protected void cmdView_Click(object sender, EventArgs e)
  2.     {    
  3. //ReadWriteData is a class   
  4.         ReadWriteData rwd = new ReadWriteData();
  5.         string sb = rwd.ReadFile(@"C:\Documents and Settings\pa_mukeshk\My Documents\Visual Studio 2008\Execute 1.0.docx");
  6.         Session["FileData"] = sb;
  7.         Response.Redirect("~/HomePages/ViewPage.aspx", true);
  8. //ReadWriteData class has below method
  9. public string ReadFile(string path)
  10.     {
  11.         FileStream fstream = new FileStream(path, FileMode.Open, FileAccess.Read);
  12.         StreamReader sreader = new StreamReader(fstream, System.Text.Encoding.UTF8);
  13.         string sr = sreader.ReadToEnd();
  14.         return sr;
  15.     }
  16. //on the load of ViewPage.aspx,i have
  17. protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         if (!IsPostBack)
  20.         {
  21.             string sb = (string)Session["FileData"];
  22.             Label lt = new Label();
  23.             lt.Text = sb.ToString();
  24.             myPanel.Controls.Add(lt);
  25.         }
  26.     }
  27.  
Feb 9 '12 #1
0 1575

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lam | last post by:
Hi the default readline method in StreamReader read the text from the top to bottom how can I read a text file from the bottom to the top? Thanks
15
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
2
by: I_AM_DON_AND_YOU? | last post by:
Can BinaryReader Object read the Word file?
3
by: kymjay | last post by:
I am trying to read a file in with the following code and I am getting a system.nullreferenceexception error. The error is “object reference not set to an instance of an object”. This is my...
4
by: Robert | last post by:
How can I read a file in, make the contents of the file the body of an email message and then email it? I want to read an HTML file in and send an HTML formatted email message.
4
by: funkmusha | last post by:
I am trying to read a log file using vb.net. I get an error stating "The process cannot access the file 'C:\test.log' because it is being used by another process." Below is a sample of what I am...
5
by: sang | last post by:
How to read the .doc file into the printable format(ie without ascii code). It's urgent pls anyone help me Thanks Sang
1
by: SJ | last post by:
Dear Friends, In my Asp file I have the binary for a Microsoft Word document that I read from an email attachement. Does anyone know how I can get the text out of the binary format? Do I have...
4
by: Alexander Vasilevsky | last post by:
Need to read Word file without Office installation. It's possible? http://www.alvas.net - Audio tools for C# and VB.Net developers
1
by: cathy25 | last post by:
Hi, I am using the following code to read a file. DirectoryInfo dir = new DirectoryInfo(@"C:\"); try { if (dir.Exists) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.