If Functions.Execute("SHOUQUAN",args(0),"上传附件") Then
Dim ftp1 As new ftpclient
ftp1.host="csfdaf$@$@"
ftp1.Account = "dasfdaf"
ftp1.password = "dafdaf"
Dim fl As String
Dim t As Table=Tables(args(0))
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
fl=dlg.FileName
If fl<>"" Then
Dim r As Row=Tables("文件管理").addnew
r("文档类别")=args(0)
r("文件关联号")=t.current("_identify")
r("crc")=CRCCheckFile(fl)
Dim ifo As new FileInfo(fl)
r("文件创建时间")=ifo.CreationTime
r("文件名称")=Ifo.name.replace(ifo.Extension,"")
r("后缀名")=ifo.Extension
r("最后一次访问时间")=ifo.LastWriteTime
r("最后一次修改时间")=ifo.LastAccessTime
' r("文件大小")=Ifo.Length
Dim k As Double=Ifo.Length/1024
Select Case k
Case >1024
r("文件大小")=math.round(k/1024,2) & "MB"
Case <1024
r("文件大小")=math.round(k,0) & "KB"
End Select
Dim ml As String="\" & args(0)
If ftp1.DirExists(ml)=False Then
ftp1.MakeDir(ml)
End If
ml=ml & "\" & Format(Date.Today,"yyyy")
If ftp1.DirExists(ml)=False Then
ftp1.MakeDir(ml)
End If
ml=ml & "\" & Format(Date.Today,"MM")
If ftp1.DirExists(ml)=False Then
ftp1.MakeDir(ml)
End If
ml=ml & "\" & Format(Date.Today,"dd")
If ftp1.DirExists(ml)=False Then
ftp1.MakeDir(ml)
End If
ml=ml & "\" & t.current(Functions.Execute("返回父表关联列名称",args(0)))
If ftp1.DirExists(ml)=False Then
ftp1.MakeDir(ml)
End If
ftp1.upload(fl,ml & "\" & Ifo.name,True)
If ftp1.FileExists(ml & "\" & Ifo.name) Then
'' MessageBox.show(Ifo.name & "上传成功!","提示")
r("目录")=ml & "\" & Ifo.name
MessageBox.show( r("目录"))
Else
MessageBox.show(Ifo.name & "上传失败!","提示")
r.Delete
End If
DataTables("文件管理").save
ftp1.Close
End If
End If
Else
MessageBox.show("您无权上传文件!","提示")
End If