新聞中心
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ì)的了解。

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括武陵源網(wǎng)站建設(shè)、武陵源網(wǎng)站制作、武陵源網(wǎng)頁(yè)制作以及武陵源網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(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)輻射到武陵源省份的部分城市,未來(lái)相信會(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)方法就為大家介紹到這里。
【編輯推薦】
- VB.NET水晶報(bào)表優(yōu)點(diǎn)及結(jié)果描述
- VB.NET指針在實(shí)際應(yīng)用中作用體現(xiàn)
- VB.NET List實(shí)用技巧詳解
- VB.NET文件名排序輕松掌握
- VB.NET IEnumerator接口操作代碼解讀
網(wǎng)頁(yè)名稱:輕松打造VB.NET文件合并示例
瀏覽地址:http://m.fisionsoft.com.cn/article/dpjdgei.html


咨詢
建站咨詢
