掃二維碼與項(xiàng)目經(jīng)理溝通
我們在微信上24小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
VB.NET編程語言在文件的操作方面體現(xiàn)了非常大的作用。比如今天要為大家介紹的VB.NET文件合并,就可以應(yīng)用VB.NET來輕松的實(shí)現(xiàn)。大家就一起來具體的解讀這段代碼來對此進(jìn)行一個(gè)詳細(xì)的了解。

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括武陵源網(wǎng)站建設(shè)、武陵源網(wǎng)站制作、武陵源網(wǎng)頁制作以及武陵源網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,武陵源網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到武陵源省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
VB.NET文件合并代碼實(shí)現(xiàn)示例:
- 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
VB.NET文件合并的相關(guān)實(shí)現(xiàn)方法就為大家介紹到這里。
【編輯推薦】

我們在微信上24小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流