Ejemplo n.º 1
0
        public List <Staff> ReadACSVFile(string fileLocation)
        {
            FileInfo fileInfo = new FileInfo(fileLocation);

            length = fileInfo.Length;
            myform.progressBarMinimumAccessor(0);
            myform.progressBarMaximumAccessor(100);
            currentPosition = 0;
            myform.progressBarValueAccessor(0);
            using (var reader = new StreamReader(fileLocation)) //var is implicitly type
            {
                List <Staff> staffList = new List <Staff>();
                while (!reader.EndOfStream)
                {
                    // var line = reader.ReadLine();
                    line = reader.ReadLine();
                    var values = line.Split(',');

                    Staff staff = new Staff(Convert.ToInt32(values[0]), values[1], values[2], values[3], Convert.ToDouble(values[4]), values[5], values[6], values[7], Convert.ToInt32(values[8]), values[9], values[10], values[11], values[12], values[13]);
                    Console.WriteLine(values[12]);
                    staffList.Add(staff);
                    UpdateProgressBar();
                }

                return(staffList);
            }
        }
Ejemplo n.º 2
0
        public void WriteACSVFile(string fileName, List <Staff> staffList)
        {
            length           = staffList.Count;
            writeCursorValue = 0;
            myform.progressBarMinimumAccessor(0);
            myform.progressBarMaximumAccessor(100);
            myform.progressBarValueAccessor(0);

            using (StreamWriter writeText = new StreamWriter(fileName))
            {
                foreach (var staff in staffList)
                {
                    text = staff.Id.ToString() + ',' + staff.Name + ',' + staff.Surname + ',' + staff.Address + ',' + staff.Salary.ToString() + ',' + staff.City + ',' + staff.Experience.ToString() + ',' + staff.ForeignLanguage + ',' + staff.HowManyForeignLanguage + ',' + staff.Education + ',' + staff.FamilyStatus + ',' + staff.Role + ',' + staff.Picture + ',' + staff.Type;
                    writeText.WriteLine(text);
                    UpdateProgressBar();
                }
            }
        }