09-30-2012, 12:01 PM
I created this little code snippet. Hopefully this is what you were looking for, or something like it:
[code2=vbnet]Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim downloadFilePath As String = "http://brandonsoft.com/Trinity%20Webbrowser.zip?f=11&sid=e4e94d2692431bd601f36f919bfc743e"
Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
If Not (My.Computer.FileSystem.DirectoryExists(desktopPath & "/Downloads")) Then
My.Computer.FileSystem.CreateDirectory(desktopPath & "/Downloads")
End If
'Now we need to simply determine the format of the online file
Dim extensionString As String = System.IO.Path.GetExtension(downloadFilePath)
My.Computer.Network.DownloadFile(downloadFilePath, desktopPath & "/Downloads/download" & GetWebExtension(extensionString))
End Sub
Public Function GetWebExtension(ByVal partialString As String) As String
partialString = partialString.Remove(0, 1)
'Now we need to eliminate any extra chars that aren't alphanumerical
For i As Integer = 1 To partialString.Length Step 1
Dim subString As String = partialString.Substring(0, i)
For Each character As Char In subString
If Not (Char.IsNumber(character) Or Char.IsLetter(character) Or Char.IsWhiteSpace(character)) Then
Return ("." & partialString.Substring(0, i - 1))
End If
Next
Next
Return ("." & partialString)
End Function[/code2]
[code2=vbnet]Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim downloadFilePath As String = "http://brandonsoft.com/Trinity%20Webbrowser.zip?f=11&sid=e4e94d2692431bd601f36f919bfc743e"
Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
If Not (My.Computer.FileSystem.DirectoryExists(desktopPath & "/Downloads")) Then
My.Computer.FileSystem.CreateDirectory(desktopPath & "/Downloads")
End If
'Now we need to simply determine the format of the online file
Dim extensionString As String = System.IO.Path.GetExtension(downloadFilePath)
My.Computer.Network.DownloadFile(downloadFilePath, desktopPath & "/Downloads/download" & GetWebExtension(extensionString))
End Sub
Public Function GetWebExtension(ByVal partialString As String) As String
partialString = partialString.Remove(0, 1)
'Now we need to eliminate any extra chars that aren't alphanumerical
For i As Integer = 1 To partialString.Length Step 1
Dim subString As String = partialString.Substring(0, i)
For Each character As Char In subString
If Not (Char.IsNumber(character) Or Char.IsLetter(character) Or Char.IsWhiteSpace(character)) Then
Return ("." & partialString.Substring(0, i - 1))
End If
Next
Next
Return ("." & partialString)
End Function[/code2]