问题描述
在过去的几个月里,每个人都在这里建立一个带有聊天功能的文件服务器,现在我不想问太多,所以我可以从网络上提取大部分代码.
它有什么:
用户列表
登录到服务器(.xml文件服务器端)
有一些管理员cmd's
下载文件
聊天. ect ect
到目前为止一切正常,但是我想做的是将文件和文件夹添加到树形视图中,因为atm我使它从列表视图和组合框运行,但是只能更改一个目录(我知道为什么),所以我在想,如果我将其移至树状视图,则可以存储完整路径,并具有图标和所有其他很酷的东西.
我知道的事情:
线程(一点点让我前进)
网络流
控制台应用程序(因为它开始就是这样)
我不知道的事情:
以树状视图进行线程处理(我无法使其正常工作).
将字符串中的文件加载到根节点,并设置树状视图以获取文件\文件夹列表(具有存储的完整路径).
它可能看起来很多,但我无法在树状视图中列出服务器上列出文件\文件夹的任何内容.
我很抱歉的拼写我知道它的失败,但你可以做什么:)
无论如何,您都希望得到我的帮助.
服务器正在执行此操作:
Hey there every one for the past few months i have been building a file server with chat, now i dont like to ask much so i have work most of the code out from then net.
What it has:
User List
Login to server(.xml file server side)
has some admin cmd''s
download files
chat. ect ect
all that works well so far but what i would like to do is add the files and folders to a tree view because atm i have it running from a list view and combo box but one can only change down one dir( i know why) so im thinking if i move it over to a tree view i can stor the full path and have icons and all that cool stuff.
things i know:
threading(a lil bit to get me going)
network streams
console app(coz it started like that)
things i dont know:
threading with a tree view( i cant get it to work right).
loading files from strings in to root nodes and setting up the tree veiw to take a file\folder list(with stored fullpath).
it may seem like a lot but i cant find any thing on listing files\folders on a server in a tree view.
im sorry for the spelling i know its fail but what can ya do :)
any way ty for your time and i would love a lil help.
the server is doing this:
Public Sub DisplayTree(ByVal DirTree As String, ByVal Client As tcpConnection)
Dim NameDir As IO.DirectoryInfo
'FIrst Folder and File list
If IO.Directory.Exists(DirTree) Then
For Each MyDir As String In IO.Directory.GetDirectories(DirTree)
NameDir = New IO.DirectoryInfo(MyDir)
SendOnlineUsersToCLIENT(Client, 87, NameDir.Name & "$", "" + "$", NameDir.Name + "$")
If IO.Directory.Exists(NameDir.ToString) Then
For Each MyDir1 As String In IO.Directory.GetFiles(NameDir.ToString)
NameDir = New IO.DirectoryInfo(MyDir1)
SendOnlineUsersToCLIENT(Client, 87, NameDir.Name & "$", "" + "$", NameDir.Name + "$")
Next
End If
If IO.Directory.Exists(MyDir) Then
Call DisplayTree(MyDir, Client)
End If
Next
For Each MyDir As String In IO.Directory.GetFiles(DirTree)
NameDir = New IO.DirectoryInfo(MyDir)
SendOnlineUsersToCLIENT(Client, 87, NameDir.Name & "$", "" + "$", NameDir.Name + "$")
Next
End If
End Sub
客户端正在执行此操作:
client is doing this :
Private Sub client_ChatReceived(ByVal Sender As tcpConnection, ByVal msgTag As String, _
ByVal mstream2 As String, ByVal mstream3 As String, ByVal mstream As String) Handles client.Chat
Select Case msgTag
Case Requests.MSG
UpdateStatus4("<Global>" & " " & mstream3 & ": " & cryptout(mstream, mstream))
Case Requests.ServerMSG
UpdateStatus4("<Server Msg>" & " " & mstream3 & " " & mstream)
Case Requests.Tell
UpdateStatus4("<PM>" & " " & mstream3 & ": " & cryptout(mstream, mstream))
Case Requests.ONLINEUSERS
Dim dfdsf = frmMain.TreeView1.Nodes.ContainsKey(mstream2)
If dfdsf = False Then
UpdateStatus78(mstream2)
End If
Case Requests.loginFail
UpdateStatus4("<User Log>" & " " & mstream3 & " " & mstream)
Case Requests.OFFLINEUSERS
Dim dsads As New TreeNode
dsads.Name = mstream3
frmMain.TreeView1.Nodes.RemoveByKey(mstream3)
UpdateStatus4("<User Log>" & " " & mstream3 & " " & mstream)
Case 101
UpdateStatus4(mstream2 & " " & mstream2 & ": " & mstream)
Case 87
UpdateStatus782(mstream2)
End Select
End Sub
而案例87对此表示遗憾,要发布孔块,但我认为这会有所帮助:
and case 87 is calling this sorry to post the hole block but i figerd it would help:
Public Sub UpdateStatus782(ByVal t As String)
Try
frmMain.TreeView2.Nodes.Add(t, t, 4, 4)
Catch e As Exception
If frmMain.TreeView2.InvokeRequired Then
Dim str_text As String = CStr(t)
Dim d As New Node(AddressOf UpdateStatus782)
frmMain.TreeView2.Invoke(d, New String() {str_text})
End If
End Try
End Sub
推荐答案
这篇关于文件服务器VB.net 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!