加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB.Net实现文件合并的实例

发布时间:2020-12-16 23:27:09 所属栏目:大数据 来源:网络整理
导读:VB.NET实现文件合并的实例 Code: Private Sub MergeFiles( ByVal inputDir As String , ByVal inputMask As String , ByVal outputPath As String ) 'storefilesindatatablewiththeircreatedtimestosortbylater Dim files As New DataTable files.Columns.Ad

VB.NET实现文件合并的实例

Code:
  1. PrivateSubMergeFiles(ByValinputDirAsString,ByValinputMaskAsString,ByValoutputPathAsString)
  2. 'storefilesindatatablewiththeircreatedtimestosortbylater
  3. DimfilesAsNewDataTable
  4. files.Columns.Add("filepath",GetType(String))
  5. files.Columns.Add("creationtime",GetType(Date))
  6. 'findpartialfiles
  7. ForEachfAsStringInIO.Directory.GetFiles(inputDir,inputMask)
  8. files.Rows.Add(NewObject(){f,IO.File.GetCreationTime(f)})
  9. Next
  10. 'makesureoutputfiledoesnotexistbeforewriting
  11. IfIO.File.Exists(outputPath)Then
  12. IO.File.Delete(outputPath)
  13. EndIf
  14. 'loopthroughfileinorder,andappendcontentstooutputfile
  15. ForEachdrAsDataRowInfiles.Select("","creationtime")
  16. DimcontentsAsString=My.Computer.FileSystem.ReadAllText(CStr(dr("filepath")))
  17. My.Computer.FileSystem.WriteAllText(outputPath,contents,True)
  18. Next
  19. EndSub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读