• vb 读取指定路径文件名


    Private Sub ExportCostSheetData()
            InsertRow("")
            InsertRow("Run 2:Export CostingSheet=========================")
            InsertRow("Status:System Connectting DataBase!")
            If ConnJWeb() = False Or ConnJWeb2() = False Then
                InsertRow("Status:System Connectting DataBase fialed!")
                AddRow("", "", "Status:System Connectting DataBase fialed!", "system")
                Exit Sub
                ' GoTo End1
            End If
            Dim CurrentComp As Integer
            Dim strDestFolder As String = "\1.1.1.1BogartCostingCostSheet"
            Dim rsR As New ADODB.Recordset
            Dim Flag As String = selectValue(" select top 1 flag from CostingSheetFileInfo ", adoJWeb, 0)
            Try
    
                Dim strFiles() As String = Directory.GetFiles(strDestFolder)
                Dim strFile As String
                Dim AbsolutePath As String
                Dim strFilePresent As String
    
                rsR.Open("select * from CostingSheetFileInfo ", adoJWeb, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                For Each strFile In strFiles
                    strFilePresent = Path.GetFileName(strFile)
                    AbsolutePath = strDestFolder & strFilePresent
                    Dim netCmd As New OleDb.OleDbCommand("P_DeleteRecord", netJWeb)
                    netCmd.CommandType = CommandType.StoredProcedure
                    netCmd.Parameters.Add("@FileName", strFilePresent)
                    netCmd.Parameters.Add("@FileType", "Complete Costing")
                    netCmd.ExecuteNonQuery()
                    rsR.AddNew()
                    rsR.Fields("FileName").Value = strFilePresent
                    rsR.Fields("FileType").Value = "Complete Costing"
                    rsR.Fields("AbsolutePath").Value = AbsolutePath
                    rsR.Fields("LastUpdateDate").Value = Now()
                    rsR.Fields("Flag").Value = IIf(Flag = 0, "1", "0")
                    rsR.Update()
                    InsertRow(strFilePresent & "===OK!")
                    CurrentComp = CurrentComp + 1
                    Me.ProgressBar1.Value = (CurrentComp / strFiles.Length) * 100
                Next
                rsR.Close()
            Catch ex As Exception
                SendEmail()
                InsertRow("===Open Folder Fail===")
                InsertRow("End Time:" & Now)
                Exit Sub
            End Try
    
    
            adoJWeb.Execute("Update CostingSheetFileInfo set flag='" & IIf(Flag = 0, "1", "0") & "' where flag is null ")
            adoJWeb.Execute(" delete from CostingSheetFileInfo where flag='" & Flag & "'")
            '  InsertRow(" Total error records:" & strFiles.r & "")
            InsertRow("")
            InsertRow("***************** System export result *******************")
    
            InsertRow("")
            InsertRow("End Time:" & Now)
            InsertRow("***************************************************************")
    
    
        End Sub
  • 相关阅读:
    仪器的接口类型
    FIREDAC用于LINUX报头文件FireDAC.VCLUI.Wait找不到
    咏南中间件网站框架
    UNIGUI下载文件
    UNIGUI上传文件
    unigui回车代替TAB
    DELPHI开发LINUX桌面程序
    TDiocpCoderTcpServer 使用
    UNIGUI换版本注意事项
    git 撤销提交的文件
  • 原文地址:https://www.cnblogs.com/vinsonLu/p/3464931.html
Copyright © 2020-2023  润新知