以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  代码请教  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=96417)

--  作者:cuicuibing
--  发布时间:2017/2/20 15:34:00
--  代码请教
批量上传几千个图片,根据   图纸号 列的问件自动查找图片,建立目录上传。

图纸号        图片列
gg-01      
gg-02
gg-011
gg-021

图片信息

gg-01 hh0112.jpg     gg-01 hh0112-1.jpg
gg-011 hh0221.jpg   gg-011 hh0221-1.jpg
gg-02 hh0335.jpg     gg-02 hh0335-1.jpg
gg-021 hh0338.jpg   gg-021 hh0338-1.jpg

通过以下代码上传, gg01  的把 gg-01   gg-011 的都上传了。

gg-01 hh0112.jpg  中间是空格

请教如何修改代码,上传  gg-01的,不把gg-011 的上传上去。




Dim path As String = "d:\\test\\"
Dim ftp1 As New FtpClient
ftp1.Host="127.0.0.1"
ftp1.Account = "test"
ftp1.Password = "test"
ftp1.UTF8 = True

For Each dr As DataRow In DataTables("表A").Select("图纸号 is not null")
    Dim path As String = "/" & dr("图纸号") & "/"
    If ftp1.DirExists(path) = False Then ftp1.MakeDir(path)
    Dim str As String = ""
    For Each f As String In FileSys.GetFiles(path)
        If FileSys.GetName(f).StartsWith(dr("图纸号")) Then
            If ftp1.Upload(f, fpath & filesys.GetName(f)) = True Then
                str &= fpath & FileSys.GetName(f) & vbcrlf
                output.show("上传:" & filesys.GetName(f) & " 成功")
            Else
                output.show("上传:" & filesys.GetName(f) & " 失败")
            End If
        End If
    next
    dr("图片列") = str
Next
ftp1.close


--  作者:有点色
--  发布时间:2017/2/20 15:40:00
--  

If FileSys.GetName(f).StartsWith(dr("图纸号")) Then

 

改成

 

If FileSys.GetName(f).Split(" ")(0) = dr("图纸号") Then