P
Peter Jausovec
Hi,
I think you should run it in a separate thread.
I think you should run it in a separate thread.
Peter Jausovec said:Hi,
I think you should run it in a separate thread.
--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
CK said:I need a windows service that listens to a directory , if any xml file is
placed in the directory it reads it and calls a class and receives a
string.. this is the code I came up with. it works but it kills my
processor after a few min. what should i do??
Thanks
private void button6_Click(object sender, System.EventArgs e)
{
NewClaims.clsNewClaims objNewClaimI = new NewClaims.clsNewClaims();
while (true)
{
//Get the File in the directory
DirectoryInfo dir = new DirectoryInfo(@"C:\test4");
FileInfo[] xmlfiles = dir.GetFiles("*.xml");
foreach( FileInfo file in xmlfiles)
{
string strHMI="";
//Opens an existing UTF-8 encoded text file for reading.
StreamReader sr = File.OpenText(file.FullName);
string data= sr.ReadToEnd();
strHMI = objNewClaimI.ConvertNewClaimsXmlUICIToHMItxt(data);
int intExtension=file.Name.IndexOf(".");
FileInfo outputFile = new
FileInfo(@"c:\test5\"+file.Name.Substring(0,intExtension)+".txt");
StreamWriter strWriter =new StreamWriter(File.Open(@"c:\test5\" +
file.Name.Substring(0,intExtension) +".txt",FileMode.Create,
FileAccess.Write ));
strWriter.Flush();
strWriter.Write(strHMI.ToString());
strWriter.Close();
sr.Close();
file.Delete();
}
}
}