Ejemplo n.º 1
0
        public static FileStats AnalyzeFile(string FileContent)
        {
            FileStats result = new FileStats();
            result.WordCount = CountWordsInString(FileContent);
            result.LineCount = CountLinesInString(FileContent);

            return result;
        }
Ejemplo n.º 2
0
        public ActionResult UploadFile()
        {
            //recieving file from form
            HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;

            //converting file contenttosting
            string FileContent = new StreamReader(hpf.InputStream).ReadToEnd();

            //processingfile content
            FileStats result = new FileStats();
            result = FileAnalyzer.AnalyzeFile(FileContent);
            result.FileName = Path.GetFileName(hpf.FileName);

            //adding file to db
            fileStatsRepository.InsertFileStats(result);
            fileStatsRepository.Save();

            //displaying results
            return View("Index", result);
        }