コード例 #1
0
        public static IList <T> ReadTableData <T>(string fileFold, string fileName) where T : new()
        {
            string fileImport = System.IO.Path.Combine(fileFold, fileName);

            var dictTable = new List <T>();

            try
            {
                StreamReader readerFile = new StreamReader(fileImport, Encoding.GetEncoding("windows-1250"));
                if (!readerFile.EndOfStream)
                {
                    string colltext    = readerFile.ReadLine();
                    var    lineColumns = UtilsTable.GetColumns(colltext);

                    while (!readerFile.EndOfStream)
                    {
                        string valstext  = readerFile.ReadLine();
                        T      valueItem = new T();
                        UtilsTable.ParseDataUseNames(valueItem, lineColumns, valstext);

                        dictTable.Add(valueItem);
                    }
                }
                readerFile.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
            }
            return(dictTable);
        }