2

I have one function ParseHtmlTable(string htmlContent).

Now in that function I want to pass the content of the html file. Now can I do by writing only filename with its path.Then I have to read that file.But I dont how to read this file ?

Then how to open particular file and read the contents of the file and send those contents to parameter of the function ?

EDIT : System.IO.File.ReadAllText(path) can read all the html file but there is one file which I have it is not read through this function.What is the reason can be there ? And for that what can be the solution ?

Harikrishna
  • 4,185
  • 17
  • 57
  • 79

1 Answers1

4

Have you tried using

string s = System.IO.File.ReadAllText( path );

File.ReadAllText Method (String)

EDIT to comment

To itterate the files in a directory you can try using Directory.GetFiles Method (String)

foreach (string filename in Directory.GetFiles(path))
{
    //do what you need here
}
Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
  • 1
    Rad up on the class System.IO.Directory. – Jonathan Allen Mar 04 '10 at 06:16
  • I have not worked with **agilityPack** before, but I would personally not try parsing html with regex... http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html – Adriaan Stander Mar 04 '10 at 06:24
  • So there is no difference that we want to parse the html text or html table content in bot case we can use same parser ? – Harikrishna Mar 04 '10 at 06:28
  • Sir..System.IO.File.ReadAllText(path) can read all the html file but there is one file which I have it is not read through this function.What is the reason can be there ? And for that what can be the solution ? – Harikrishna Mar 15 '10 at 11:28