gautam_reddyc
asked on
Windows Service - File Watcher -- read comma delimited values
Hi.. i have to read the comma delimited values from the text file.. and put each value in a string variable..
For example:
TextFile.txt
01,goutham,reddy,hyderabad .
I have to read those values and display in string
str id = 01
str firstname = gautam
str lastname = reddy
address = hyderabad
BTW, I am writing this in the Windows Service (C#). So i need to use the file watcher to check when the txt files is deployed in the folder..
Please help
For example:
TextFile.txt
01,goutham,reddy,hyderabad
I have to read those values and display in string
str id = 01
str firstname = gautam
str lastname = reddy
address = hyderabad
BTW, I am writing this in the Windows Service (C#). So i need to use the file watcher to check when the txt files is deployed in the folder..
Please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
{
string pathToDirectory = "";//path to directory to watch goes here
//the second argument below assumes that the files with the student info have the txt extension.
//if it is a different extension adjust the parameter.
studentFSW = new FileSystemWatcher(pathToDi
studentFSW.Created += new FileSystemEventHandler(stu
studentFSW.EnableRaisingEv
WebServiceProxyClass proxy = new WebServiceProxyClass();
}
void studentFSW_Created(object sender, FileSystemEventArgs e)
{
//Here we handle each of the student files as they are created. If the process that is filling the
//files with data takes some time you might want to put a very short pause in here.
Student stu = new Student();
StreamReader sr = File.OpenText(e.FullPath);
while (!sr.EndOfStream)
{
string nextLine = sr.ReadLine();
// what to code here... i need to take values seperated by comma and put them in a string variables.. as explained in my question
}
proxy.GetDetails(stu);
}