搜索: 标题内容作者  
  首页VB.NET教程VB.NET进阶教程
背景:
阅读新闻

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

[日期:2008-09-20]   来源:互联网整理  作者:佚名   [字体: ]
    新闻简介:VB.Net实现文件合并的实例
        关 键 词:   vb.net  .NET  实现  VB  实例 

vb.net实现文件合并的实例


Private Sub MergeFiles(ByVal inputDir As String, ByVal inputMask As String, ByVal outputPath As String)

 
    'store files in datatable with their created times to sort by later

    Dim files As New DataTable

    files.Columns.Add("filepath", GetType(String))

    files.Columns.Add("creationtime", GetType(Date))

    'find partial files

    For Each f As String In IO.Directory.GetFiles(inputDir, inputMask)

        files.Rows.Add(New Object() {f, IO.File.GetCreationTime(f)})

    Next



    'make sure output file does not exist before writing

    If IO.File.Exists(outputPath) Then

        IO.File.Delete(outputPath)

    End If

 

    'loop through file in order, and append contents to output file

    For Each dr As DataRow In files.Select("", "creationtime")

        Dim contents As String = My.Computer.FileSystem.ReadAllText(CStr(dr("filepath")))

        My.Computer.FileSystem.WriteAllText(outputPath, contents, True)

    Next

 

End Su

If you believe an article violates your rights or the rights of others, please contact us.

收藏 推荐 打印 | 录入:admin | 阅读:
相关新闻      
友情链接
本文评论   [发表评论] 全部评论 (2)
第 2 楼
匿名 发表于 2008-12-29 15:54:21
为啥不支持汉字合并啊???
第 1 楼
匿名 发表于 2008-12-2 19:37:02
不错
赞助商广告
热门评论