c# - Read Specific Value from .txt file and storing it in a variable -
i looking read .txt
file in c# specific value store in value example have text file, example.txt
, having several lines searching line states damian:2014/12/04
then store 2014/12/04
initialized value example datetime storedate;
using example managed read lines in file , search specific file, dont know how store , trim capture date , date interchangeable the date follows im trying get.
int counter = 0; datetime storedate; string line; streamreader file = new streamreader(@"c:\example.txt"); while ((line = file.readline()) != null) { if (line.contains("damian:")) // im stuck next } file.close();
if(line.contains("damian:")) storedate = datetime.parse(line.replace("damian:","").trim());
would simplest way grab date you're after.
Comments
Post a Comment