Wednesday, October 21, 2015

Write CSV

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] lines = { "First , line", "Second , line", "Third , line" };
            System.IO.File.WriteAllLines(@"C:\Users\Dilupa\Desktop\WriteLinesnew.csv", lines);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            using (System.Net.WebClient myWebClient = new System.Net.WebClient())
            {
                myWebClient.DownloadFile("https://data.sparkfun.com/output/QG1OzOQjoXHnKo14brWx.csv", "stream_QG1OzOQjoXHnKo14brWx.csv");
            }
        }
    }
}