Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<String> malformedLines = new List<string>(); //keep track of all malformed lines in a row and then add them together then write the line
- string line = "";
- using (StreamReader reader = new StreamReader(filepath))
- {
- using (StreamWriter writer = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/dbfiles/temp.NFPOX")))
- {
- while ((line = reader.ReadLine()) != null)
- {
- var trimmedLine = line.Trim();
- Match match = startsWith.Match(trimmedLine,);
- Match matchXML = startsWithXML.Match(trimmedLine);
- Match matchEnd = endsWith.Match(trimmedLine);
- Match matchRootStart = startRoot.Match(trimmedLine);
- Match matchRootEnd = endRoot.Match(trimmedLine);
- if ((matchXML.Success || matchRootStart.Success || matchRootEnd.Success) ||
- (match.Success && matchEnd.Success))
- {
- if(brokenLinesFound > 0)
- {
- brokenLinesFound = 0;
- var fixedLine = malformedLines.
- }
- writer.WriteLine(line);
- }
- else if (!match.Success)
- {
- brokenLinesFound += 1;
- found_broken_lines = true;
- if(brokenLinesFound > 0)
- {
- malformedLines.Add(trimmedLine);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement