public async Task <IActionResult> UploadVideo(List <IFormFile> VideoPath) { try { if (VideoPath != null) { string nameVideo = Path.GetFileName(VideoPath[0].FileName); string nameFolderCourse = "Test"; string pathUpload = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\resource\videos", nameFolderCourse); string savePath = Path.Combine(pathUpload, nameVideo); string saveDBPath = Path.Combine(@"\resource\videos", nameFolderCourse, nameVideo); var a = Directory.Exists(Path.GetDirectoryName(pathUpload)); if (!Directory.Exists(pathUpload)) { Directory.CreateDirectory(pathUpload); } using (var stream = new FileStream(savePath, FileMode.Create)) { await VideoPath[0].CopyToAsync(stream); } WareHouse wareHouse = new WareHouse(); wareHouse.NameFolder = nameFolderCourse; wareHouse.NamePath = saveDBPath; wareHouse.NameFile = nameVideo; await _wareHouseService.CreateAsync(wareHouse); return(Json(new { result = true, namevideo = nameVideo, pathvideo = saveDBPath })); } } catch (Exception ex) { return(Json(new { result = false })); } return(Json(new { result = false })); }