'Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)

when i deploy my project at kubernetes this will appears...when i run this in local system it is working fine.

at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)\n at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)\n at System.IO.File.Open(String path, FileMode mode)\n at DBHandler.Business.CustomerStatementRepository.CustStatDateWise_Quadient(CustStatementDateWise csd, String ChannelID, String OurBranchId, String ConnString, String clientip) in /src/DBHandler/Business/CustomerStatementRepository.cs:line 1364\n
at API.Controllers.CustomerStatementController.CustStatDateWise(CustomerStatementDto Model) in /src/API/Controllers/CustomerStatementController.cs:line 85

string DEST2 = string.Concat("OutputPDFs/"); //string[] DEST3 = { WebRootPath, @"\OutputPDFs"}; //string fullPath = Path.Combine(DEST3); string passProtected = _config["GlobalParamters:IsPDFPasswordProtected"].ToString(); if (passProtected == "1") {                   
 string LastName = gad.LastName;
                    string LastFour = LastName.Substring(LastName.Length - 4);
                    string LastnameLower = LastFour.ToLower();
                    DateTime DateOFB = (DateTime)gad.DOB;
                    string DateOFBstr = DateOFB.ToString("ddMM");
                    string Password = LastnameLower + DateOFBstr;
                    string OwnerPassword = LastnameLower + DateOFBstr;


                    //string DEST2 = string.Concat("OutputPDFs/");
                    Dictionary<string, string> GetEncryptedPDF = rhp.GetEncryptedPDF(DEST, mdata, FileName, DEST2, Password, OwnerPassword);
                    if (GetEncryptedPDF["RetStat"].Equals("Error"))
                    {
                        throw new Exception(GetEncryptedPDF["RetMsg"]);
                    }
                    else
                    {
                        encryptedBase64 = GetEncryptedPDF["encryptedBase64"];
                    }
                }
                Boolean iStatement = false;
                if (passProtected == "0")
                {
                    string currentDirName = Directory.GetCurrentDirectory();
                    currentDirName = currentDirName + "\\OutputPDFs\\";
                    //currentDirName = currentDirName + fullPath;

                    if (!Directory.Exists(currentDirName))
                        Directory.CreateDirectory(currentDirName);

                    using (FileStream pdfDest = File.Open(DEST, FileMode.OpenOrCreate))
                    {
                        ConverterProperties converterProperties = new ConverterProperties();
                        HtmlConverter.ConvertToPdf(mdata, pdfDest, converterProperties);
                    }
                    //start
                    byte[] bytes = File.ReadAllBytes(DEST);
                    using (MemoryStream stream = new MemoryStream())
                    {
                        PdfReader reader = new PdfReader(bytes);
                        using (PdfStamper stamper = new PdfStamper(reader, stream))
                        {
                            int pages = reader.NumberOfPages;
                            for (int i = 1; i <= pages; i++)
                            {
                                ColumnText.ShowTextAligned(stamper.GetUnderContent(i), Element.ALIGN_RIGHT, new Phrase("Page "+i.ToString()+" of "+pages), 568f, 15f, 0);
                            }
                        }
                        bytes = stream.ToArray();
                    }
                    File.WriteAllBytes(DEST, bytes);

                   
                    byte[] pdfBytes = File.ReadAllBytes(DEST);
                    encryptedBase64 = Convert.ToBase64String(pdfBytes);

                    if (File.Exists(Path.Combine(DEST2, FileName)))
                    {
                        File.Delete(Path.Combine(DEST2, FileName));
                    }
                }


Sources

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

Source: Stack Overflow

Solution Source