zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    PHP 使用 header()实现重定向
    PHP抑制符号 @
    PHP自动加载spl_autoload_register
    打开PHP错误提示
    通过htaccess使用伪静态
    用反引号(``)标注表明或者字段名,防止跟 mysql关键字冲突
    Bootstrap 弹出框(Popover)插件
    jQuery 的 validator 验证,以及添加自定义验证规则。
    线程与并发(一) 多线程基础
    SpringCloud入门
  • 原文地址:https://www.cnblogs.com/vinsonLu/p/3464931.html
Copyright © 2011-2022 走看看