C # reads a TXT file in fixed text format
A simple C # program that reads TXT documents, which hold instance data in a fixed format.
//determine if the keyword exists in the document varIsTr = File.ReadAllLines ("1.txt"). Any (x = X.split (',')[0] =="Equipment id:107157061"). ToString (); //gets the first piece of data in the sequence that satisfies the query criteria varA = File.ReadAllLines ("1.txt"). First (x = X.split (',')[0] =="Equipment id:108167353"); //gets the last piece of data in a sequence that satisfies the query criteria varb = File.ReadAllLines ("1.txt"). LastOrDefault (x = X.split (',')[0] =="Equipment id:108167353"); //to query all data that meets the criteria and return a generic collection based on where varc = File.ReadAllLines ("1.txt"). Where (x = X.split (',')[0] =="Equipment id:108167353"). ToList (); //returns all data in a document as a generic collection varAA = File.ReadAllLines ("1.txt"). ToList (); foreach(varIteminchAA) { varBB = Item. Split (','). ToList (); }
C # reads a TXT file in fixed text format