public async Task <string> Upload(IEnumerable <IFormFile> files) { string uniqueShortFolderName = _guidService.GenShortUniqueName(); string destinationPath = _appEnvironment.ContentRootPath + @"\Files\"; try { foreach (var file in files) { if (file != null) { Directory.CreateDirectory(destinationPath + uniqueShortFolderName); var typeFile = Path.GetExtension(file.FileName); var fileName = @"\" + Path.GetFileNameWithoutExtension(file.FileName); string filePath = destinationPath + uniqueShortFolderName + fileName + typeFile; await using var stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); await file.CopyToAsync(stream); } } return(uniqueShortFolderName); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(null); }