开发者

How do I read the file content and sent those content to the functions parameter

开发者 https://www.devze.com 2022-12-21 18:09 出处:网络
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

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 whic开发者_开发知识库h I have it is not read through this function.What is the reason can be there ? And for that what can be the solution ?


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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号