我没有得到第一种方法的答案,即使用 Web 浏览器组件下载,但我得到了从“临时 Internet 文件”文件夹复制的替代方法。
这是我的代码片段,它正在为我完成这项工作。
Private Function get_Image(ByVal src As String)
'******* code for storing Images from temporary internet files folder.......
Dim filename As String = get_File()
Dim gifFiles As String() = Directory.GetFiles("C:\Documents and Settings\123\Local Settings\Temporary Internet Files\", "*.*", SearchOption.AllDirectories)
Dim imgno As Integer = 0
For Each file As String In gifFiles
'Dim fsi As String = Directory.GetLastWriteTime(file).ToString
If My.Computer.FileSystem.FileExists(file) And file.Contains("attachDisplay") And Not filename.Contains("File") Then ' This is HardCoded part for my images that are having dynamic url as my base_URL/attachDisplay?_XYZ (so in temp it is storing as attachDisplay[i]; i=1,2...)
Dim curFileDT As Date = Directory.GetLastWriteTime(file)
If Date.Compare(lastFileDT, curFileDT) = -1 Then ' if Last file date is before than current File write time
imgno += 1
My.Computer.FileSystem.CopyFile(file, filename & " Img No." & imgno & file.Substring(file.LastIndexOf(".")), True)
End If
End If
Next
lastFileDT = Date.Now 'My lastFileDT variable is declared at class level and first initialization at form load.
'*******
End Function
这不是下载图像的正确方法,但它目前正在为我完成这项工作。