[高分悬赏贴500] VB.NET2005 怎么用VB.NET下载FTP上的某个文件夹及文件夹中的所有文件到本地
[高分悬赏贴500] VB.NET2005 如何用VB.NET下载FTP上的某个文件夹及文件夹中的所有文件到本地?
VB.NET2005 如何用VB.NET下载FTP上的某个文件夹及文件夹中的所有文件到本地并保持下载的文件夹中文件的目录结构和文件名一致。?
资料查了不少,没做出来。。。。。。 高手帮忙。。。。
http://topic.****.net/u/20090317/10/89181bba-73f2-4857-992c-337e704238ed.html
这一贴也一并结。
500分,现在一贴只能发100分,测试没问题开剩余4贴结分。
------解决方案--------------------
这个不太难,先获取文件列表,在本地建立跟FTP一样的目录结构,然后一个个文件下载就是了。
明天有时间的话给你把代码贴上来。
------解决方案--------------------
oFTP = New nBitFTP.clsFTP()第三方控件。nBit Information Technologies
oFTP.Host = "www. 1234.com"
oFTP.UserName = "1234"
oFTP.Password = "1234"
Me.ListBox1.Items.Clear()
Dim wjj As New System.Collections.ArrayList
If oFTP.connect() = True Then '创建连接
If oFTP.GetDirectoryListing("*.*") = True Then
For X As Int32 = 0 To oFTP.Directory.Count - 1
Dim Wmc As String = oFTP.Directory.Item(X + 1).FileName
If oFTP.Directory.Item(X + 1).Directory = True And Wmc <> "." And Wmc <> ".." Then
wjj.Add(Wmc)
End If
Next
End If
End If
Dim Js As Int16 = 0
While wjj.Count <> Js
Js = wjj.Count
If oFTP.connect() = True Then '创建连接
For xh As Int32 = 0 To wjj.Count - 1
If oFTP.GetDirectoryListing(wjj(xh)) = True Then
For X As Int32 = 0 To oFTP.Directory.Count - 1
Dim Wmc As String = oFTP.Directory.Item(X + 1).FileName
If oFTP.Directory.Item(X + 1).Directory = True Then
If oFTP.Directory.Item(X + 1).Directory = True And Wmc <> "." And Wmc <> ".." _
And wjj.Contains(wjj(xh) & "/" & Wmc) = False Then
wjj.Add(wjj(xh) & "/" & Wmc)
End If
End If
Next
End If
Next
End If
End While
For xh As Int32 = 0 To wjj.Count - 1
Me.ListBox1.Items.Add(wjj(xh))
If IO.Directory.Exists(Me.TextBoxsave.Text & "/" & wjj(xh)) = False Then
IO.Directory.CreateDirectory(Me.TextBoxsave.Text & "/" & wjj(xh))
End If
Dgwj(wjj(xh))
Next
Me.ToolStripProgressBar1.Visible = True
Dim Xzjs As Int32 = 0
Me.ToolStripProgressBar1.Maximum = Me.DataGridVieFile.Rows.Count - 1
Dim Xzjl As New System.Collections.SortedList
For xh As Int32 = 0 To Me.DataGridVieFile.Rows.Count - 1
Dim Wmc As String = Me.DataGridVieFile.Rows(xh).Cells(0).Value
Dim Bdwj As String = Me.TextBoxsave.Text & "/" & Wmc
Dim Wjcd As Int32 = Me.DataGridVieFile.Rows(xh).Cells(2).Value
Dim Xgsj As Date = Me.DataGridVieFile.Rows(xh).Cells(3).Value
If IO.File.Exists(Bdwj) = False Then
Xzjs += 1
Me.Label1下载数量.Text = Xzjs
Xzjl.Add(Wmc, Bdwj)
Else
If New IO.FileInfo(Bdwj).Length < Wjcd Or New IO.FileInfo(Bdwj).LastWriteTime < Xgsj Then
Xzjs += 1
Me.Label1下载数量.Text = Xzjs
Xzjl.Add(Wmc, Bdwj)
End If
End If
Me.ToolStripProgressBar1.Value = xh
Next
Me.ToolStripProgressBar1.Maximum = Xzjl.Count - 1
VB.NET2005 如何用VB.NET下载FTP上的某个文件夹及文件夹中的所有文件到本地并保持下载的文件夹中文件的目录结构和文件名一致。?
资料查了不少,没做出来。。。。。。 高手帮忙。。。。
http://topic.****.net/u/20090317/10/89181bba-73f2-4857-992c-337e704238ed.html
这一贴也一并结。
500分,现在一贴只能发100分,测试没问题开剩余4贴结分。
------解决方案--------------------
这个不太难,先获取文件列表,在本地建立跟FTP一样的目录结构,然后一个个文件下载就是了。
明天有时间的话给你把代码贴上来。
------解决方案--------------------
oFTP = New nBitFTP.clsFTP()第三方控件。nBit Information Technologies
oFTP.Host = "www. 1234.com"
oFTP.UserName = "1234"
oFTP.Password = "1234"
Me.ListBox1.Items.Clear()
Dim wjj As New System.Collections.ArrayList
If oFTP.connect() = True Then '创建连接
If oFTP.GetDirectoryListing("*.*") = True Then
For X As Int32 = 0 To oFTP.Directory.Count - 1
Dim Wmc As String = oFTP.Directory.Item(X + 1).FileName
If oFTP.Directory.Item(X + 1).Directory = True And Wmc <> "." And Wmc <> ".." Then
wjj.Add(Wmc)
End If
Next
End If
End If
Dim Js As Int16 = 0
While wjj.Count <> Js
Js = wjj.Count
If oFTP.connect() = True Then '创建连接
For xh As Int32 = 0 To wjj.Count - 1
If oFTP.GetDirectoryListing(wjj(xh)) = True Then
For X As Int32 = 0 To oFTP.Directory.Count - 1
Dim Wmc As String = oFTP.Directory.Item(X + 1).FileName
If oFTP.Directory.Item(X + 1).Directory = True Then
If oFTP.Directory.Item(X + 1).Directory = True And Wmc <> "." And Wmc <> ".." _
And wjj.Contains(wjj(xh) & "/" & Wmc) = False Then
wjj.Add(wjj(xh) & "/" & Wmc)
End If
End If
Next
End If
Next
End If
End While
For xh As Int32 = 0 To wjj.Count - 1
Me.ListBox1.Items.Add(wjj(xh))
If IO.Directory.Exists(Me.TextBoxsave.Text & "/" & wjj(xh)) = False Then
IO.Directory.CreateDirectory(Me.TextBoxsave.Text & "/" & wjj(xh))
End If
Dgwj(wjj(xh))
Next
Me.ToolStripProgressBar1.Visible = True
Dim Xzjs As Int32 = 0
Me.ToolStripProgressBar1.Maximum = Me.DataGridVieFile.Rows.Count - 1
Dim Xzjl As New System.Collections.SortedList
For xh As Int32 = 0 To Me.DataGridVieFile.Rows.Count - 1
Dim Wmc As String = Me.DataGridVieFile.Rows(xh).Cells(0).Value
Dim Bdwj As String = Me.TextBoxsave.Text & "/" & Wmc
Dim Wjcd As Int32 = Me.DataGridVieFile.Rows(xh).Cells(2).Value
Dim Xgsj As Date = Me.DataGridVieFile.Rows(xh).Cells(3).Value
If IO.File.Exists(Bdwj) = False Then
Xzjs += 1
Me.Label1下载数量.Text = Xzjs
Xzjl.Add(Wmc, Bdwj)
Else
If New IO.FileInfo(Bdwj).Length < Wjcd Or New IO.FileInfo(Bdwj).LastWriteTime < Xgsj Then
Xzjs += 1
Me.Label1下载数量.Text = Xzjs
Xzjl.Add(Wmc, Bdwj)
End If
End If
Me.ToolStripProgressBar1.Value = xh
Next
Me.ToolStripProgressBar1.Maximum = Xzjl.Count - 1