我正在为我的GUI开发一个下载功能,允许最终用户输入一个5位数的作业号,并从FTP站点下载这些文件。在这样做,我已经能够获得目录列表,但我无法使用该列表来获取文件。任何有关所示代码的帮助都将不胜感激。
Dim UserName As String
' Sets Username to current logged-in user profile
UserName = Environment.UserName
Dim JobNo As String
JobNo = Textbox1.Text
Dim listRequest As FtpWebRequest = WebRequest.Create("ftp://ftp.site.com/INPUT/" & JobNo & "_*.DBF")
listRequest.Credentials = New System.Net.NetworkCredential(“Username”, “Password”)
listRequest.Method = WebRequestMethods.Ftp.ListDirectory
Dim listResponse As FtpWebResponse = listRequest.GetResponse()
Dim reader As StreamReader = New StreamReader(listResponse.GetResponseStream())
For Each foundFile As String In
My.Computer.Network.DownloadFile("ftp://ftp.site.com/INPUT/" & foundFile, "C:\users\” & UserName & “\desktop\temp\" & foundFile, “Username”, “Password”)
Next
答案 0 :(得分:1)
以下是有效的最终输出。整体
function download_box_content($post)
{
$music_links = get_post_meta($post->ID, 'music-links', 'false');
<input type="text" name="link-music[]" value="<?php echo $music_links ?>">
<input type="text" name="link-music[]" value="<?php echo $music_links ?>">
<input type="text" name="link-music[]" value="<?php echo $music_links ?>">
}
答案 1 :(得分:0)
我试图根据使用ListDirectory创建的列表从FTP下载文件,但它没有从阅读器中以可用格式拆分,因此无法使用我已更新我的代码并使其正常工作:
Dim UserName As String
' Sets Username to current logged-in user profile
UserName = Environment.UserName
Dim JobNo As String
JobNo = Textbox1.Text
Dim listRequest As FtpWebRequest = WebRequest.Create("ftp://ftp.site.com/INPUT/" & JobNo & "_*.DBF")
listRequest.Credentials = New System.Net.NetworkCredential(“Username”, “Password”)
listRequest.Method = WebRequestMethods.Ftp.ListDirectory
Dim listResponse As FtpWebResponse = listRequest.GetResponse()
Dim reader As StreamReader = New System.IO.StreamReader(listResponse.GetResponseStream())
Dim Filedata As String = reader.ReadToEnd
Dim directory() As String = Filedata.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
For Each foundFile As String In directory
My.Computer.Network.DownloadFile("ftp://ftp.site.com/INPUT/" & foundFile, "C:\users\” & UserName & “\desktop\temp\" & foundFile, “Username”, “Password”)
Next
更新了部分
Dim reader As StreamReader = New System.IO.StreamReader(listResponse.GetResponseStream())
Dim Filedata As String = reader.ReadToEnd
Dim directory() As String = Filedata.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)