File.Exist(RecentelyCreatedPDFUsingPdfCreator_File Path) returns false

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fastestindian
    New Member
    • Aug 2009
    • 74

    File.Exist(RecentelyCreatedPDFUsingPdfCreator_File Path) returns false

    I m working on a Sending mail functionality. In that I first create a pdf and then attach that PDF to the mail and send to the use.

    Problem
    1) is when I check for
    Code:
    strPDFFile= Server.MapPath("~/HTMLReportSource/PDFSchedules/" & "ABC.pdf")
    If File.Exists(strPDFFile) Then
                    strAttachmentPath = "~/HTMLReportSource/PDFSchedules/" & ViewState("VS2005_GENERATED_POLICY_NO") & ".pdf"
    
                Else
                    strAttachmentPath = ""
    end if
    I get value as false even though I can see the file.
    2) even If i give the path of the pdf file using
    Code:
    attach = New Attachment(System.Web.HttpContext.Current.Server.MapPath(strAttachmentPath))
                            smail.Attachments.Add(attach )
    I get exception.


    I m not sure why this happening as if I send PDFFileNamePath with previously created file, it works fine.
    But issue is with the recently created file.

    Please help me on this issue as I have already wasted lot of time on this.
    thanks in advance.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Use the debugger and check the value of the strPDFFile variable at runtime.

    Make sure it is the path that you are expecting it to be.

    -Frinny

    Comment

    • fastestindian
      New Member
      • Aug 2009
      • 74

      #3
      Path is as expected and i can see the file also but still i am not able to find the file in File.Exists().

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        On line 1 you have:
        Code:
        strPDFFile= Server.MapPath("~/HTMLReportSource/PDFSchedules/" & "ABC.pdf")
        Are you sure you are supposed to be checking if "ABC.pdf" exists?

        Or are you supposed to be looking to see if ViewState("VS20 05_GENERATED_PO LICY_NO") & ".pdf" exists?

        -Frinny

        Comment

        Working...