Read Specific Strings from Text File
I'm trying to get certain strings out of a text file and put it in a
variable. This is what the structure of the text file looks like keep in
mind this is just one line and each line looks like this and is separated
by a blank line:
Date: 8/12/2013 12:00:00 AM Source Path:
\\build\PM\11.0.64.1\build.11.0.64.1.FileServerOutput.zip Destination
Path: C:\Users\Documents\.NET
Development\testing\11.0.64.1\build.11.0.55.5.FileServerOutput.zip Folder
Updated: 11.0.64.1 File Copied: build.11.0.55.5.FileServerOutput.zip
I wasn't entirely too sure of what to use for a delimiter for this text
file or even if I should be using a delimiter so it could be subjected to
change.
So just a quick example of what I want to happen with this, is I want to
go through and grab the Destination Path and store it in a variable such
as strDestPath.
Overall the code I came up with so far is this:
//find the variables from the text file
string[] lines = File.ReadAllLines(GlobalVars.strLogPath);
Yeah not much, but I thought perhaps if I just read one line at at a time
and tried to search for what I was looking for through that line but
honestly I'm not 100% sure if I should stick with that way or not...
No comments:
Post a Comment