Select Case e.DataCol.Name Case "附件" Dim ftp1 As new ftpclient ftp1.host= "192.168.1.9" ftp1.Port= "21" ftp1.Account = "hxh" ftp1.password = "12" Dim st As String = "Photo1\" & e.DataRow("年度") & "\" & e.DataRow("分类") & "\" & e.DataRow("标签") If ftp1.DirExists(st) Then '判断目录是否存在 MessageBox.show("目录已经存在","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Else MessageBox.show("目录不存在,是否创建!","提示",MessageBoxButtons.YesNo) ftp1.MakeDir("\photo1") '逐步创建目录,FT现在还不能一次连子目录创建 ftp1.MakeDir("\photo1\" & e.DataRow("年度")) ftp1.MakeDir("\photo1\" & e.DataRow("年度") & "\" & e.DataRow("分类")) ftp1.MakeDir("\photo1\" & e.DataRow("年度") & "\" & e.DataRow("分类") & "\" & e.DataRow("标签")) ‘按照表中的年度、分类和标签建立ftp目录 ftp1.ChangeDir(st) End If '以下是在本地机器上实现的,在ftp上如何实现? Dim sm As String = e.SourceFolder & "\" & ftp1.CurrentDir Dim sn As String = e.SubFolder & "\" & ftp1.CurrentDir If ftp1.FileExists(sm) Then '如果指定的文件存在 If ftp1.DirExists(sn) MessageBox.Show("文件已经存在!","提示") e.cancel = True Return ElseIf FileIsOpened(sm)= True Then MessageBox.Show("文件已经打开!","提示") e.cancel = True Return Else Filesys.copyFile(sm,sn) '先复制 FileSys.DeleteFile(sm,2,3) '则彻底删除之 End If e.cancel = True If e.DataRow.isnull(e.DataCol.name) Then e.DataRow(e.DataCol.name) = e.filename Else e.DataRow(e.DataCol.name) = e.DataRow(e.DataCol.name) & vbcrlf & e.filename End If End If End Select
|