locked
Save an attachment to an external folder RRS feed

  • Question

  • User-2042189214 posted

    Hi,

    I need to save an attachment to an external folder.When i try to save it locally,it is success.But after publishing it doesnot work.The code is

     string UniqueFileName = null;
                if (AttachAddModel.Files != null && AttachAddModel.Files.Count > 0)
                {
                    foreach (IFormFile file in AttachAddModel.Files)
                    {
                        string UploadFolder = @"S:\IMAGE\DEMO\";
                        UniqueFileName = Guid.NewGuid().ToString() + "_" + file.FileName;
                        string FilePathNew = Path.Combine(UploadFolder, UniqueFileName);
                        file.CopyTo(new FileStream(FilePathNew, FileMode.Create));
                       
                    }
                }

    Please give me a solution

    Thursday, November 12, 2020 6:37 AM

All replies

  • User475983607 posted

    Typically, this issue is a misunderstanding.  During development the development machine is both a client and server.  When the application is moved to a server the code is no longer able to save files on the client or another location because the code is NOT running the client which has access tot he folder.  The code is running on the server. 

    Thursday, November 12, 2020 2:14 PM