private string checkFileName(string fileName)
 {
     if (!File.Exists(fileName))
     {
         return(fileName);
     }
     else
     {
         DateTime now        = DateTime.Now;
         string   extension  = Auxiliary.getExtension(fileName);
         int      lastPeriod = fileName.LastIndexOf('.');
         fileName = fileName.Substring(0, lastPeriod) + now.ToString("MM,dd,yyyy,H,mm,ss") + "." + extension;
         return(checkFileName(fileName));
     }
 }
Example #2
0
        public List <Object> readData(string fileName)
        {
            List <Object> list = new List <Object>();

            string extension = Auxiliary.getExtension(fileName);

            if (extension.Equals("txt"))
            {
                list = this.readTxtCSVFile(fileName, '\t');
            }
            else if (extension.Equals("csv"))
            {
                list = this.readTxtCSVFile(fileName, ',');
            }
            else if (extension.Equals("xls") || extension.Equals("xlsx"))
            {
                ExcelReader reader = new ExcelReader();
                DataInformation.setIfSpreadSheet(true);
                list = reader.readExcelFile(fileName, this);
            }

            return(list);
        }
Example #3
0
        public bool analyzeExtensions(string[] fileNames)
        {
            //if less than 2 files selected
            if (fileNames.Length < 2 || fileNames.Length > 2)
            {
                MessageBox.Show("inusfficient number of files selected");
                return(false);
            }

            //check if the different types were selected, if 2 similar types were selected
            HashSet <string> set = new HashSet <string>();

            foreach (string fileName in fileNames)
            {
                string extension = Auxiliary.getExtension(fileName);
                if (!set.Add(extension))
                {
                    MessageBox.Show("same type of files were selected");
                    return(false);
                }
            }
            return(true);
        }