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
|