'.NET Core 3.1 Writing file to network drive

I am trying to get user to upload a document from the web interface and have it stored on the network share *\dfsms\shared\MyProject* , it also saves the entry in a SQL table (path, filetype, content etc.). However, it seems like it's not writing the file to the directory, nor creating it. I am wondering if it's a permissions issue? Of course this works on my local version where I save to a location under my C: drive, but once it is deployed to the SERP, it does not work. The entry is recorded in the SQL table but the file is not actually saved to the directory specified. Let me know if you have any ideas.

enter image description here From my controller:

[HttpPost]
        public IActionResult UploadNotes(IFormFile files, MedicalHistoryView viewModel)
        {
            viewModel.Donation = _context.Donation.Find(viewModel.Person.PersonId);

            if (files != null)
            {
                if (files.Length > 0)

                {
                   
                   var path = Path.Combine("\\dfsms", "shared", "MyProject", viewModel.Donation.CaseNumber, "Medical History" );

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    //Getting FileName
                    var fileName = Path.GetFileName(files.FileName);
                    //Getting file Extension
                    var fileExtension = Path.GetExtension(fileName);
                    var newFileName = String.Concat(fileName, fileExtension);

                    using FileStream stream = new FileStream(Path.Combine(path, fileName), FileMode.Create);
                    files.CopyTo(stream);
                    var objfiles = new MedicalNotes()
                    {

                        PersonId = viewModel.Person.PersonId,
                        FileName = fileName,
                        FileType = fileExtension,
                        FullSizePath = Path.Combine(path, fileName),
                        CreatedOn = DateTime.Now
                    };

                    using (var target = new MemoryStream())
                    {
                        files.CopyTo(target);
                        objfiles.DataFiles = target.ToArray();
                    }
                   
                    _context.MedicalNotes.Add(objfiles);
                    _context.SaveChanges();

                }
            }
            return RedirectToAction(nameof(Details), new { id = viewModel.Person.PersonId });
        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source