Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ไม่สามารถ delete file pdf ได้ ใช้ asp.net ( the process cannot access the file because it is being used by another process)



 

ไม่สามารถ delete file pdf ได้ ใช้ asp.net ( the process cannot access the file because it is being used by another process)

 



Topic : 106053



โพสกระทู้ ( 12 )
บทความ ( 0 )



สถานะออฟไลน์




ไม่สามารถลบ file pdf ได้ โดยมี error ขึ้นมา " the process cannot access the file because it is being used by another process"
ช่วยหน่อยนะคะ

Code (VB.NET)
 If txtSubject.Text = String.Empty Then
            ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Please enter Subject.');", True)
            txtSubject.Focus()
        ElseIf txtTo.Text = String.Empty Then
            ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Please enter To.');", True)
            txtTo.Focus()
        ElseIf txtDetail.Text = String.Empty Then
            ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Please enter Detail.');", True)
            txtDetail.Focus()
        ElseIf txtCC.Text = String.Empty Then
            ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Please enter CC.');", True)
            txtCC.Focus()
        Else

            Try
                Dim rpts As CrystalDecisions.CrystalReports.Engine.ReportDocument = CType(Session("ReportDocument"), CrystalDecisions.CrystalReports.Engine.ReportDocument)
                Dim pathpdf As String = Server.MapPath(".") & "\PDFDownload\MogasAndKerosene_" & Session(USERNAME) & ".pdf"
                '  Dim pathpdf As String = Server.MapPath(".") & "\PDFDownload\MogasAndKerosene.pdf"

                Dim crExportOptions As ExportOptions
                Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions()
                Dim crFormatTypeOptions As New PdfRtfWordFormatOptions()

                crDiskFileDestinationOptions.DiskFileName = pathpdf
                crFormatTypeOptions.FirstPageNumber = 1
                crFormatTypeOptions.LastPageNumber = 3
                crFormatTypeOptions.UsePageRange = True

                crExportOptions = rpts.ExportOptions
                With crExportOptions
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    .ExportFormatType = ExportFormatType.PortableDocFormat

                    .ExportDestinationOptions = crDiskFileDestinationOptions
                    .ExportFormatOptions = crFormatTypeOptions
                End With
              
                Try
                    rpts.Export()
                    rpts.Close()
                    rpts.Dispose()
                    rpts = Nothing
                Catch ex As Exception

                End Try


                'Step SendMail
                Dim mail As New clsMail
                ' Dim mailSubject As String = "Mogas and Kerosene Update -" & txtDateNow.Text
                Dim mailForm As String = "<[email protected]>"
                '  Dim mailTo As String = "[email protected]"
                '  Dim mailCC As String = "[email protected]"
                Dim mailAtt As String = pathpdf
                Dim localPath As String = Server.MapPath("")
                Dim IsResult As Boolean = False
                '  IsResult = mail.SendMailFinish(localPath, mailForm, mailTo, mailCC, mailAtt, mailSubject)
                IsResult = mail.SendMailFinish(localPath, mailForm, mailAtt, txtSubject.Text, txtDetail.Text, txtTo.Text, txtCC.Text)
                If IsResult = True Then
                    ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Send Email Successfull');", True)
                Else
                    ScriptManager.RegisterStartupScript(Page, Page.GetType, "AlertMessage", "alert('Send Email Unsuccess');", True)
                End If
               

            Catch ex As Exception

            End Try

            tdEdit.Visible = False
            txtSubject.Text = String.Empty
            txtDetail.Text = String.Empty
            txtCC.Text = String.Empty
            txtTo.Text = String.Empty

            'Dim FileEmail As New FileInfo(Server.MapPath(".") & "\PDFDownload\MogasAndKerosene_" & Session(USERNAME) & ".pdf")

            'If FileEmail.Exists Then
            '    FileEmail.Delete()
            'Else
            'End If
        


            Dim filePaths As String() = Directory.GetFiles(Server.MapPath(".") & "\PDFDownload\", "*.pdf")
            For Each filePath As String In filePaths
                File.Delete(filePath)
            Next
          
        End If




Tag : ASP.NET Web (ASP.NET)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-02-20 15:37:01 By : toeimomo View : 1554 Reply : 2
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ก่อนหน้านี้น่าจะเรียกใช้แล้วไม่ได้ Close พวก Object ให้หมดน่ะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-20 17:10:19 By : mr.win
 


 

No. 2

Guest


Как об этом PDF processing in VB.NET?
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-12 10:37:34 By : arronlee
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ไม่สามารถ delete file pdf ได้ ใช้ asp.net ( the process cannot access the file because it is being used by another process)
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่