Created
March 23, 2016 15:13
-
-
Save biganth/35afab5ab0d5afeeadb3 to your computer and use it in GitHub Desktop.
Export a stream of data to CSV
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
FileStream fileStream = new FileStream("C:\\Temp\\EncompassExtract.csv", FileMode.Create); | |
var streamWriter = new StreamWriter(fileStream); | |
streamWriter.AutoFlush = true; | |
StringBuilder line = new StringBuilder(); | |
line.AppendFormat("User" + "," + "UserId" + "," + "Account Enabled"); | |
line.Append(Environment.NewLine); | |
foreach (User user in users) | |
{ | |
line.AppendFormat(user.FullName + "," + user.Id + "," + user.Enabled); | |
line.Append(Environment.NewLine); | |
} | |
streamWriter.WriteLineAsync(line.ToString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
33333