Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Collections.Generic;
  4. using System.IO;
  5.  
  6. namespace FinalAssm
  7. {
  8.  
  9.     static class cls_Data
  10.     {
  11.         static List<Planets> PlanetsList;
  12.        
  13.         static void mtd_InsertData()
  14.         {
  15.             const string FilePath = @"C:\Users\sergey\Desktop\Data\";
  16.  
  17.             PlanetsList = new List<Planets>();
  18.             FileStream PlanetsStream = File.OpenRead(FilePath + "Planets.csv");
  19.             var PlanetsReader = new StreamReader(PlanetsStream);
  20.            
  21.             while (!PlanetsReader.EndOfStream)
  22.             {
  23.                 string line = PlanetsReader.ReadLine();
  24.                 string[] field = line.Split(',');
  25.                 PlanetsList.Add(new Planets(field[0], field[1]));
  26.             }
  27.  
  28.             PlanetsReader.Close();
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement