Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim FileName As String
Dim FileLen As Integer
Dim UserName As String = user.Name
If e.node.Level = 1 Then '如果是二级节点
If e.node.DataRow.Isnull("文件全名") Then
MessageBox.show("此文件不许任何人查看!","提示")
ElseIf e.node.DataRow("文件可查看人").IndexOf(UserName) = -1 And (User.Type <> UserTypeEnum.Developer And User.Type <> UserTypeEnum.Administrator) Then
MessageBox.show("你没有查看此文件的权限!","提示")
Return
Else
If not e.node.DataRow.Isnull("文件全名") Then
FileName =e.node.DataRow("文件全名")
FileLen=FileName.Length-2
FileName = FileName.SubString(2,FileLen)
End If
If Not FileSys.DirectoryExists(ProjectPath & "\FileMange") Then
FileSys.CreateDirectory(ProjectPath & "\FileMange")
End If
If FileSys.FileExists(ProjectPath & "FileMange\" & FileName) Then
try
Dim aa As New System.IO.FileStream(ProjectPath & "FileMange\" & FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)
aa.Dispose()
FileSys.DeleteFile(ProjectPath & "FileMange\" & FileName,2,2) '则彻底删除之
Catch ex As Exception
MessageBox.Show("当前文件已在浏览窗口打开,不能下载同名文件,请先点击下载别的文件后,再打开!","提示",MessageBoxButtons.OK)
End Try
End If
Dim ftp1 As new ftpclient
ftp1.host="192.168.0.248"
ftp1.Account = "ytxsp"
ftp1.password = "ytx820723"
ftp1.UTF8=True
If ftp1.Connected = False '如果FTP没有连接
If ftp1.Connect Then '连接FTP
If ftp1.Download("\" & FileName,ProjectPath & "FileMange\" & FileName) = True Then
Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Form.Controls("WebBrowser1").basecontrol.Navigate(ProjectPath & "FileMange\" & FileName )
If e.Node.DataRow("文件状态") = "已审核"
e.Form.Controls("Button1").Visible= True
Else
e.Form.Controls("Button1").Visible= False
End If
Else
Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
Else
Messagebox.show("连接FTP失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End If
End If
End If