
04-20-2008, 05:13 PM
|
|
Newcomer
|
|
Join Date: Apr 2008
Posts: 1
|
|
Winsocks
|
First of all, I think it`s important to point out I`m no expert in VB. So bare with me.
I´m writting a code for a remote file manager. I`ve got the file transfer to work but my problem is in the explorer itself.
My basic idea is to have a FileListBox with all the files in the server side and, on request by the client, with a For i = 0 To Files1.ListCount - 1 make a run over each file and send them to the client. Then, on the client side, add each file name (separating them with a "|") one by one to a ListBox with a split function.
Here is the code:
Server Side:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Y As String
Dim X As String
Winsock1.GetData X, vbString
Y = Right(X, 100)
X = Left(X, 1)
Select Case X
Case "1" ' This is for files
For i = 0 To Files1.ListCount - 1
x = Files1.List(i) & "|" & x
Next i
Winsock1.SendData "File" & x
Case "2" ' This is for folders
For i = 0 To Dire.ListCount - 1
x = Dire.List(i) & "|" & x
Next i
Winsock1.SendData "Dire" & x
End Select
End Sub
On the client side:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim X As String
Dim Y As String
Dim Z As String
Winsock1.GetData X, vbString
Y = Right(X, 100)
Z = Left(X, 4)
Select Case Z
Case "Dire"
Y = Right(Y, Len(Y) - 4)
Dim fields() As String
fields() = Split(Y, "|")
For i = 0 To UBound(fields)
List2.AddItem Trim$(fields(i))
Next
End If
Case "File"
Y = Right(Y, Len(Y) - 4)
Dim fields() As String
fields() = Split(Y, "|")
For i = 0 To UBound(fields)
List1.AddItem Trim$(fields(i))
Next
End If
End Select
End Sub
|
|