تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
كيف نعالج هذا الخطأ - FormatException
#3
بصراحة وجدت طريقة افضل من اللتي لدي و حصلت  عليها من قوقل قديما
بحثت مرة اخرى لكي انسخ الكود لكن لم يظهر الكود الذي لدي الان لكن اظن انه نفس المؤدى
كود :
Using client As New WebClient()
   Dim uri As New Uri("http://example.com/download")
   Dim data As Byte() = client.DownloadData(uri)

   Dim filename As String = ""
   If client.ResponseHeaders("Content-Disposition") IsNot Nothing Then
       Dim contentDisposition As String = client.ResponseHeaders("Content-Disposition")
       ' Parse the contentDisposition string to extract the filename
       ' For example: attachment; filename="document.pdf"
       Dim parts As String() = contentDisposition.Split(";")
       For Each part As String In parts
           If part.Trim().StartsWith("filename=") Then
               filename = part.Trim().Replace("filename=", "").Replace("""", "")
               Exit For
           End If
       Next
   End If

   ' Use the extracted filename or a default one
   If String.IsNullOrEmpty(filename) Then
       filename = "default_download.bin"
   End If

   ' Save the data to the file
   System.IO.File.WriteAllBytes(filename, data)
End Using
اللهم إني أعوذ بك من غلبة الدين وغلبة العدو، اللهم إني أعوذ بك من جهد البلاء ومن درك الشقاء ومن سوء القضاء ومن شماتة الأعداء
اللهم اغفر لي خطيئتي وجهلي، وإسرافي في أمري وما أنت أعلم به مني، اللهم اغفر لي ما قدمت وما أخرت، وما أسررت وما أعلنت وما أنت أعلم به مني، أنت المقدم وأنت المؤخر وأنت على كل شيء قدير
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: كيف نعالج هذا الخطأ - FormatException - بواسطة justforit - 25-10-25, 04:19 AM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم