With System.Net.HttpWebRequest.Create("http://www.iconspedia.com/dload.php?up_id=37031") .Method = "HEAD" MsgBox(.GetResponse.Headers.ToString()) End With
Private Function GetUriFileName(ByVal Uri As String) As String Dim req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(Uri) req.Method = "HEAD" Dim headers As String = req.GetResponse.Headers.ToString() MsgBox(headers) Dim file As String = headers.Substring(headers.IndexOf("filename=") + 10) file = file.Substring(0, file.IndexOf("""")) Return file End Function
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MsgBox(GetURLFileName("http://site.com/download?=1351+azex;zae")) MsgBox(GetURLFileName("http://site.com/fichier.ext")) End Sub Private Function GetURLFileName(ByRef vsFilePath As String) As String With New System.Text.RegularExpressions.Regex("([.\w]+)(?:\?.+)?$").Match(vsFilePath) If .Success Then Return .Groups(1).Value End If End With Return String.Empty End Function End Class