How can i read HTML file automatically from a folder ,,say for every hour ?!! My requirement is to read the files from a folder automatically and store it in database. till now, i was able to read data from the HTML file(when user uploads it manually)
and store it in database. But how can i make my program to read the file automatically.
Here is the code to achive read the data from HTML file and store it in database. how can i make changes in this code so that HTML files is automatically read and store the data in database.
protected void Button1_Click(object sender, EventArgs e)
{
int inap = 0, outap = 0; if (FileUpload1.HasFile) { string htmldata; StreamReader file = new StreamReader(FileUpload1.FileContent); htmldata = file.ReadToEnd();
}
NOTE : This is not the complete code, i've removed all the busniess logic part, coz i want to show how am reading the file and how can i automate this code to read automatically. If you need more information on this or complete code, pls let me know.
You can use methods in the
Directory class to get a list of files. You can either use the GetFiles or EnumerateFiles method and then process each file in the collectio nthat is returned.
Pradeep pooj...
Member
2 Points
6 Posts
How to read HTML files recursively from a folder.
Feb 23, 2012 04:13 AM|LINK
Hello all,
How can i read HTML file automatically from a folder ,,say for every hour ?!! My requirement is to read the files from a folder automatically and store it in database. till now, i was able to read data from the HTML file(when user uploads it manually) and store it in database. But how can i make my program to read the file automatically.
Here is the code to achive read the data from HTML file and store it in database. how can i make changes in this code so that HTML files is automatically read and store the data in database.
protected void Button1_Click(object sender, EventArgs e)
{
int inap = 0, outap = 0;
if (FileUpload1.HasFile)
{
string htmldata;
StreamReader file = new StreamReader(FileUpload1.FileContent);
htmldata = file.ReadToEnd();
}
NOTE : This is not the complete code, i've removed all the busniess logic part, coz i want to show how am reading the file and how can i automate this code to read automatically. If you need more information on this or complete code, pls let me know.
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: How to read HTML files recursively from a folder.
Feb 23, 2012 06:31 AM|LINK
You can use methods in the Directory class to get a list of files. You can either use the GetFiles or EnumerateFiles method and then process each file in the collectio nthat is returned.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter