以文本方式查看主题

-  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=53881)

--  作者:sjx71
--  发布时间:2014/7/17 13:09:00
--  [求助]文件名称自动更改和自动编号

在照片列增加照片,照片可以存在动态设置的文件夹内,文件名可以改为 小区+(住址)+日期+"-01.jpg"

 

但同一单元格内增加第二张照片时,就需要手动更改文件名为 。。。+"-02.jpg"

 

我想用 filesys.getname  filesys.getfiles  SpecialFolder 等几个方法组合实现自动编号,但一直未实现。

 

请教各位老师,如何实现自动编号

 

谢谢

 

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:文件名称自动编号.foxdb


--  作者:有点甜
--  发布时间:2014/7/17 14:24:00
--  
Dim ext As String
ext = e.FileName.SubString(e.FileName.LastIndexof(".") + 1)
Select Case e.DataCol.Name
    Case "照片"
        If ext = "jpg" Then
            Dim path1 As String   = e.DataRow("安检日期").year & "\\" & e.DataRow("小区") & "\\" & e.DataRow("住址")
            e.SubFolder = path1
            e.filename = e.DataRow("小区") & "(" & e.DataRow("住址") & ")" & Format(e.DataRow("安检日期"),"yyyyMMdd")
            Dim count As Integer = 1
            If FileSys.DirectoryExists(ProjectPath & "Attachments\\" & path1) Then
                For Each file As String In FileSys.GetFiles(ProjectPath & "Attachments\\" & path1)
                    If file Like "*" & e.FileName & "*" Then
                        count += 1
                    End If
                Next
            End If
            e.FileName &= "-" & Format(count, "00") & ".jpg"
        Else
            MessageBox.Show("此列只能插入jpg文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            e.Cancel = True
        End If
End Select

--  作者:sjx71
--  发布时间:2014/7/17 22:35:00
--  

多谢老师


--  作者:方丈
--  发布时间:2014/10/1 15:14:00
--  
记号