Skip to content

Instantly share code, notes, and snippets.

@awrowse
Last active December 10, 2015 07:08
Show Gist options
  • Save awrowse/4399494 to your computer and use it in GitHub Desktop.
Save awrowse/4399494 to your computer and use it in GitHub Desktop.
CSVParse.cs
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