Last active
December 10, 2015 07:08
-
-
Save awrowse/4399494 to your computer and use it in GitHub Desktop.
CSVParse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
using Microsoft.VisualBasic.FileIO; | |
namespace SSOTester { | |
public partial class Form1 : Form { | |
public Form1() { | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) { | |
textBox1.Text = ""; | |
using (TextFieldParser parser = new TextFieldParser(@"C:\Users\andy.rowse\Desktop\csv.txt")) { | |
parser.Delimiters = new string[] { "," }; | |
while (true) { | |
string[] parts = parser.ReadFields(); | |
if (parts == null) { | |
break; | |
} | |
textBox1.Text += String.Format("{0} field(s)" + Environment.NewLine, parts.Length); | |
foreach (var field in parts) { | |
textBox1.Text += String.Format("{0}" + Environment.NewLine, field); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment