成都网站建设设计

将想法与焦点和您一起共享

轻松打造VB.NET文件合并示例

VB.NET编程语言在文件的操作方面体现了非常大的作用。比如今天要为大家介绍的VB.NET文件合并,就可以应用VB.NET来轻松的实现。大家就一起来具体的解读这段代码来对此进行一个详细的了解。

成都创新互联服务项目包括武陵源网站建设、武陵源网站制作、武陵源网页制作以及武陵源网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,武陵源网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到武陵源省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

VB.NET文件合并代码实现示例:

 
 
 
  1. Private Sub MergeFiles(ByVal 
    inputDir As String, ByVal 
    inputMask As String, ByVal 
    outputPath As String)  
  2. 'store files in datatable 
    with their created times 
    to sort by later  
  3. Dim files As New DataTable  
  4. files.Columns.Add("filepath",
     GetType(String))  
  5. files.Columns.Add("creationtime",
     GetType(Date))  
  6. 'find partial files  
  7. For Each f As String In IO.
    Directory.GetFiles(inputDir, inputMask)  
  8. files.Rows.Add(New Object() 
    {f, IO.File.GetCreationTime(f)})  
  9. Next  
  10. 'make sure output file does
     not exist before writing  
  11. If IO.File.Exists(outputPath) Then  
  12. IO.File.Delete(outputPath)  
  13. End If  
  14. 'loop through file in order, 
    and append contents to output file  
  15. For Each dr As DataRow In 
    files.Select("", "creationtime")  
  16. Dim contents As String = 
    My.Computer.FileSystem.ReadAllText
    (CStr(dr("filepath")))  
  17. My.Computer.FileSystem.WriteAllText
    (outputPath, contents, True)  
  18. Next  
  19. End Su 

 VB.NET文件合并的相关实现方法就为大家介绍到这里。

【编辑推荐】

  1. VB.NET水晶报表优点及结果描述
  2. VB.NET指针在实际应用中作用体现
  3. VB.NET List实用技巧详解
  4. VB.NET文件名排序轻松掌握
  5. VB.NET IEnumerator接口操作代码解读

本文标题:轻松打造VB.NET文件合并示例
文章来源:https://chengdu.cdxwcx.cn/article/dpjdgei.html