自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

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

開(kāi)發(fā) 后端
VB.NET文件合并這一操作方法,在文件操作中是一個(gè)比較常見(jiàn)的操作。大家可以跟隨本文給出的代碼示例,進(jìn)行一番實(shí)踐編寫(xiě),加深對(duì)此的印象。

VB.NET編程語(yǔ)言在文件的操作方面體現(xiàn)了非常大的作用。比如今天要為大家介紹的VB.NET文件合并,就可以應(yīng)用VB.NET來(lái)輕松的實(shí)現(xiàn)。大家就一起來(lái)具體的解讀這段代碼來(lái)對(duì)此進(jìn)行一個(gè)詳細(xì)的了解。

VB.NET文件合并代碼實(shí)現(xiàn)示例:

  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文件合并的相關(guān)實(shí)現(xiàn)方法就為大家介紹到這里。

【編輯推薦】

  1. VB.NET水晶報(bào)表優(yōu)點(diǎn)及結(jié)果描述
  2. VB.NET指針在實(shí)際應(yīng)用中作用體現(xiàn)
  3. VB.NET List實(shí)用技巧詳解
  4. VB.NET文件名排序輕松掌握
  5. VB.NET IEnumerator接口操作代碼解讀
責(zé)任編輯:曹凱 來(lái)源: 中國(guó)IT實(shí)驗(yàn)室
相關(guān)推薦

2010-01-11 15:12:30

VB.NET特殊窗體

2009-10-29 15:02:04

VB.NET文件排序

2010-01-14 10:07:08

VB.NET文件名排序

2009-10-27 16:18:58

VB.NET復(fù)制刪除文

2010-01-13 18:28:21

VB.NET歷史菜單

2009-11-03 09:37:33

VB.NET重載

2010-01-18 15:01:02

VB.NET異常迭代捕

2009-10-30 14:45:42

Flash控制VB.N

2010-01-13 17:47:59

VB.NET拖放

2010-01-14 13:59:01

2010-01-11 18:40:03

VB.NET操作注冊(cè)表

2010-01-18 19:36:52

VB.NET調(diào)整控件

2009-10-29 16:36:49

VB.NET .DLL

2010-01-14 13:08:37

VB.NET運(yùn)算符

2009-10-28 17:08:57

VB.NET數(shù)據(jù)庫(kù)開(kāi)發(fā)

2009-11-02 12:35:10

VB.NET追加文件

2010-01-08 10:48:05

VB.NET多線程

2010-01-19 17:03:25

VB.NET可執(zhí)行語(yǔ)句

2010-01-13 15:12:04

VB.NET字符串合并

2009-10-29 15:16:02

VB.NET文件傳送
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)