예제 #1
0
        private async Task <string> ExtractRawTextAsync(IFormFile formFile)
        {
            var tempDirectory = Path.Combine(Directory.GetParent(hostingEnvironment.WebRootPath).FullName, "App_Data", "Temp");

            if (!Directory.Exists(tempDirectory))
            {
                Directory.CreateDirectory(tempDirectory);
            }
            var fileName = formFile.ExtractFileName();
            var fullpath = Path.Combine(tempDirectory, formFile.GetHashCode() + new FileInfo(fileName).Name);
            await formFile.SaveAsAsync(fullpath);

            var extension = fileName.Substring(fileName.LastIndexOf('.'));
            var wrapped   = WrapperFactory[extension](fullpath);

            return(await wrapped.LoadTextAsync());
        }