Ejemplo n.º 1
0
        public static List <string> GetNumberList(this HttpPostedFileBase file)
        {
            string contenido = new StreamReader(file.InputStream).ReadToEnd();

            string[] arraytxt  = contenido.Split(',');
            string[] arraycsv  = contenido.Split(';');
            var      extencion = file.GetFileExtention();
            var      texto     = new List <string>();
            var      list      = new List <string>();

            if (extencion == FileExtention.txt)
            {
                texto = arraytxt.ToList();
            }
            else if (extencion == FileExtention.csv)
            {
                texto = arraycsv.ToList();
            }
            else if (extencion == FileExtention.undefinned)
            {
                return(new List <string>());
            }


            foreach (var item in texto.ToList())
            {
                var split_item = item.Replace("\r\n", "").Replace("\n", "").Replace("\r", "").Replace(" ", "").ToString();
                if (split_item == "" || !split_item.IsNumeric() || split_item.Length < 6)
                {
                }
                else
                {
                    list.Add(split_item);
                }
            }
            return(list);
        }