符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
思路:
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了新市免费建站欢迎大家使用!
1,使用ListBox1控件来存放搜索到的文件名,然后ListBox1.SelectedItem就可以返回选中项的文本;
2,利用获得的选中项文本(即文件与路径),使用打开文本文件的方法,读取内容显示在文本框里。
public strData as string
'这段可以返回服务器中的第一级目录名,保存在strData中, 如有多个文件夹名每个文件夹名会以空格分开。读取时判段一下。
Inet1.Execute Inet1.URL, "dir """ dirName """"
Do
DoEvents
Loop While Inet1.StillExecuting = True
msgbox strData
'这段是进入目录中,要想获得服务器中所有的文件夹名,就可以用递规的办法来获得。
Inet1.Execute Inet1.URL, "cd """ dirName """"
Do
DoEvents
Loop While Inet1.StillExecuting = True
Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 1
StatusBar1.Panels.Item(1).Text = "该控件正在查询所指定的主机的 IP 地址"
Case 2
StatusBar1.Panels.Item(1).Text = "该控件已成功地找到所指定的主机的 IP 地址"
Case 3
StatusBar1.Panels.Item(1).Text = "该控件正在与主机连接"
Case 4
StatusBar1.Panels.Item(1).Text = "该控件已与主机连接成功"
Case 5
StatusBar1.Panels.Item(1).Text = "该控件正在向主机发送请求"
Case 6
StatusBar1.Panels.Item(1).Text = "该控件发送请求已成功"
Case 7
StatusBar1.Panels.Item(1).Text = "该控件正在接收主机的响应"
Case 8
StatusBar1.Panels.Item(1).Text = "该控件已成功地接收到主机的响应"
Case 9
StatusBar1.Panels.Item(1).Text = "该控件正在解除与主机的连接"
Case 10
StatusBar1.Panels.Item(1).Text = "该控件已成功地与主机解除了连接"
Case 11
MsgBox "与主机通讯时出现了错误", vbInformation, "个人资料"
Case 12
Dim vtData As Variant
Dim bDone As Boolean
bDone = False
'取得第一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData vtData
'取得下一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents
If Len(vtData) = 0 Then
bDone = True
End If
Loop
StatusBar1.Panels.Item(1).Text = "该请求已经完成,并且所有数据均已接收到"
Case Else
StatusBar1.Panels.Item(1).Text = Inet1.ResponseCode ": " Inet1.ResponseInfo
End Select
End Sub
If My.Computer.Network.IsAvailable Then
'如果可用
Else
'不可用
End If
Public Sub DownloadFile ( _
address As Uri, _
destinationFileName As String, _
userName As String, _
password As String, _
showUI As Boolean, _
connectionTimeout As Integer, _
overwrite As Boolean, _
onUserCancel As UICancelOption _
)
参数
address
String 或 Uri。要下载的文件的路径,包括文件名和主机地址。必选。
destinationFileName
String。下载文件的文件名和路径。必选。
userName
String。要进行身份验证的用户名。默认值为空字符串 ""。
password
String。要进行身份验证的密码。默认值为空字符串 ""。
showUI
Boolean。指定是否显示操作进度。默认为 False。
connectionTimeout
Int32。以毫秒为单位的超时间隔。默认值为 100 秒。
overwrite
Boolean。指定是否改写现有文件。默认为 False。
onUserCancel
UICancelOption。指定当用户在对话框(此对话框在 ShowUI 设置为 True 时显示)上单击“取消”或“否”时的行为。默认为 ThrowException。
步骤如下:
窗体上添加2个列表框,一个按钮:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyDir As String = "C:\123"
'搜索并显示子文件夹
ListBox1.Items.Clear()
For Each MySubDir As String In System.IO.Directory.GetDirectories(MyDir)
ListBox1.Items.Add(MySubDir)
Next
'搜索并显示文件
ListBox2.Items.Clear()
For Each MyFile As String In System.IO.Directory.GetFiles(MyDir)
ListBox2.Items.Add(MyFile)
Next
End Sub
End Class
具体方法如下:”、打开Serv-U的配置管理界面puzb在“全局用户”或者“域用户”中选择“创建cgko修改和删除用户帐户”; 2、在“创建,修改和删除用户帐户”的界面,选择“添加”。;3、在“用户属性“对话框,“用户信息”下的用户名为:Anonymous,密码为空,为其指定FTP的根目录。 4、然后在“目录访问“选项,点击“添加”,为其指定访问权限和目录。 5、最后点击“保存”6这样我们就成功添加了匿名用户。
MSDN上的,看看对你有没有帮助。GOOD LUCK!
Imports System.Net
Imports System.IO
Module FtpSample
Sub Main(ByVal args() As String)
If args.Length = 0 OrElse args(0).Equals("/?") Then
DisplayUsage()
ElseIf args.Length = 1 Then
Download(args(0))
ElseIf args.Length = 2 Then
If args(0).Equals("/list") Then
List(args(1))
Else
Upload(args(0), args(1))
End If
Else
Console.WriteLine("Unrecognized argument.")
End If
End Sub
Private Sub DisplayUsage()
Console.WriteLine("USAGE:")
Console.WriteLine(" FtpSample [/? | FTP download URL | local file")
Console.WriteLine(" FTP upload URL | /list FTP list URL]")
Console.WriteLine()
Console.WriteLine("where")
Console.WriteLine(" FTP download URL URL of a file to download from an FTP server.")
Console.WriteLine(" FTP upload URL Location on a FTP server to upload a file to.")
Console.WriteLine(" FTP list URL Location on a FTP server to list the contents of.")
Console.WriteLine(" local file A local file to upload to an FTP server.")
Console.WriteLine()
Console.WriteLine(" Options:")
Console.WriteLine(" /? Display this help message.")
Console.WriteLine(" /list Specifies the list command.")
Console.WriteLine()
Console.WriteLine("EXAMPLES:")
Console.WriteLine(" Download a file FtpSample ")
Console.WriteLine(" Upload a file FtpSample upload.txt ")
End Sub
Private Sub Download(ByVal downloadUrl As String)
Dim responseStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim reader As StreamReader = Nothing
Try
Dim downloadRequest As FtpWebRequest = _
WebRequest.Create(downloadUrl)
Dim downloadResponse As FtpWebResponse = _
downloadRequest.GetResponse()
responseStream = downloadResponse.GetResponseStream()
Dim fileName As String = _
Path.GetFileName(downloadRequest.RequestUri.AbsolutePath)
If fileName.Length = 0 Then
reader = New StreamReader(responseStream)
Console.WriteLine(reader.ReadToEnd())
Else
fileStream = File.Create(fileName)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = responseStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
fileStream.Write(buffer, 0, bytesRead)
End While
End If
Console.WriteLine("Download complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
ElseIf responseStream IsNot Nothing Then
responseStream.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
End Try
End Sub
Private Sub Upload(ByVal fileName As String, ByVal uploadUrl As String)
Dim requestStream As Stream = Nothing
Dim fileStream As FileStream = Nothing
Dim uploadResponse As FtpWebResponse = Nothing
Try
Dim uploadRequest As FtpWebRequest = WebRequest.Create(uploadUrl)
uploadRequest.Method = WebRequestMethods.
' UploadFile is not supported through an Http proxy
' so we disable the proxy for this request.
uploadRequest.Proxy = Nothing
requestStream = uploadRequest.GetRequestStream()
fileStream = File.Open(fileName, FileMode.Open)
Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
requestStream.Write(buffer, 0, bytesRead)
End While
' The request stream must be closed before getting the response.
requestStream.Close()
uploadResponse = uploadRequest.GetResponse()
Console.WriteLine("Upload complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As IOException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Finally
If uploadResponse IsNot Nothing Then
uploadResponse.Close()
End If
If fileStream IsNot Nothing Then
fileStream.Close()
End If
If requestStream IsNot Nothing Then
requestStream.Close()
End If
End Try
End Sub
Private Sub List(ByVal listUrl As String)
Dim reader As StreamReader = Nothing
Try
Dim listRequest As FtpWebRequest = WebRequest.Create(listUrl)
listRequest.Method = WebRequestMethods.
Dim listResponse As FtpWebResponse = listRequest.GetResponse()
reader = New StreamReader(listResponse.GetResponseStream())
Console.WriteLine(reader.ReadToEnd())
Console.WriteLine("List complete.")
Catch ex As UriFormatException
Console.WriteLine(ex.Message)
Catch ex As WebException
Console.WriteLine(ex.Message)
Finally
If reader IsNot Nothing Then
reader.Close()
End If
End Try
End Sub
End Module
可以通过设置 Credentials 属性来指定用于连接服务器的凭据,也可以将它们包含在传递给 Create 方法的 URI 的 UserInfo 部分中。
从 FTP 服务器下载文件时,如果命令成功,所请求的文件的内容即在响应对象的流中。通过调用 GetResponseStream 方法,可以访问此流。
如果使用 FtpWebRequest 对象向服务器上载文件,则必须将文件内容写入请求流,请求流是通过调用 GetRequestStream 方法或其异步对应方法(BeginGetRequestStream 和 EndGetRequestStream 方法)获取的。必须写入流并在发送请求之前关闭该流。
请求是通过调用 GetResponse 方法或其异步对应方法(BeginGetResponse 和 EndGetResponse 方法)发送到服务器的。请求的操作完成时,会返回一个 FtpWebResponse 对象。FtpWebResponse 对象提供操作的状态以及从服务器下载的所有数据。