473,320 Members | 1,958 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,320 software developers and data experts.

help me remove the junk values from html files...in c# 2008

51
hi,hope atleast this question would b answered...
Am using C# 2008
Am reading a html file

using :

streamreader sr = new streamreader(path,Encoding.DEfault);

string input = sr.Read();

streamwriter sw = new streamwriter(path);

sw.Write(input);
sw.Close();




here the html file initially is proper but after writing it takes junk character which is visible through the browser

..thanx...
Mar 20 '08 #1
6 2173
Sick0Fant
121 100+
hi,hope atleast this question would b answered...
Am using C# 2008
Am reading a html file

using :

streamreader sr = new streamreader(path,Encoding.DEfault);

string input = sr.Read();

streamwriter sw = new streamwriter(path);

sw.Write(input);
sw.Close();




here the html file initially is proper but after writing it takes junk character which is visible through the browser

..thanx...
rdr.Read() reads one char. You want rdr.ReadToEnd()
Mar 20 '08 #2
Smish
51
rdr.Read() reads one char. You want rdr.ReadToEnd()
i read it using s.REadToEnd(); too
but still the problem is same...:(
Mar 21 '08 #3
Sick0Fant
121 100+
i read it using s.REadToEnd(); too
but still the problem is same...:(
Okay, what are these "junk" values of which you speak?
Mar 22 '08 #4
Smish
51
i have pasted the code snippet which am using here....

StreamReader sr = File.OpenText(G:\\HtmlReports\\Original.htm);
string input = sr.ReadToEnd();
input = input.Trim();
StreamWriter strWriter = new StreamWriter("G:\\HtmlReports\\ReplacedHtm.htm");
strWriter.Write(input);


The junk values which am able to see in the browser is
"���� " or sme other format...


the html file has space in betwen to beautify the document namely " (a)<span style='mso-spacerun:yes'> </span>Apple</span>" and whn i read this file through streamreader the space ie betwn "'mso-spacerun:yes'>" and "</span>"is encoded in to these junk values ..hence am geting these junk values..

So do you kno any means to remove them ??

thanx
Mar 22 '08 #5
Sick0Fant
121 100+
i have pasted the code snippet which am using here....

StreamReader sr = File.OpenText(G:\\HtmlReports\\Original.htm);
string input = sr.ReadToEnd();
input = input.Trim();
StreamWriter strWriter = new StreamWriter("G:\\HtmlReports\\ReplacedHtm.htm");
strWriter.Write(input);


The junk values which am able to see in the browser is
"���� " or sme other format...


the html file has space in betwen to beautify the document namely " (a)<span style='mso-spacerun:yes'> </span>Apple</span>" and whn i read this file through streamreader the space ie betwn "'mso-spacerun:yes'>" and "</span>"is encoded in to these junk values ..hence am geting these junk values..

So do you kno any means to remove them ??

thanx
Well, the whitespace didn't matter in my test... I always was able to get the html document without the junk.

If all you're doing is moving one file to another location, .NET has a method to do that which is much more efficient than writing the file yourself.

But anyway, I would suspect that those spaces are actually characters that can't be displayed by your editor (though usually, it's been my experience that they at least display *something*--usually a smiley face or something). The quickest way to test this theory is go back to your editor and delete all the "whitespace" where you're getting the junk and replace it with spaces or tabs. If you're still getting the junk, you'll want to watch the input variable after you've read the document, to see if it's getting read correctly.

Come back if you still get junk.
Mar 22 '08 #6
Smish
51
If i remove the white space thn it works fine..but thn the files cming from the user would be in any format..so hw to remove these whitespaces???
Mar 22 '08 #7

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

Similar topics

3
by: Phil Powell | last post by:
<?php class FileRemoval { var $fileNameArray, $isRemoved, $errorMsg = ''; function FileRemoval() { $this->fileNameArray = array(); $this->isRemoved = 0; }
163
by: Shiperton Henethe | last post by:
Hi Know any good utilities to help me strip out the tags that Microsoft Excel 2002 leaved behind when you try and export an HTML format file? This is driving me NUTS. And really makes me...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.