新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
VB.NET文件夾操作相關(guān)技巧分享
編程人員利用VB.NET進(jìn)行實(shí)際編程,可以輕松簡(jiǎn)便的完成各種功能。比如今天為大家介紹的VB.NET在對(duì)文件夾的操作上,就可以輕松的實(shí)現(xiàn)各種操作。下面就讓我們一起來(lái)看看VB.NET文件夾操作相關(guān)應(yīng)用技巧。

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的保靖網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
VB.NET文件夾操作之文件夾復(fù)制
- Function CopyDir()Function CopyDir
(ByVal sourcePath As String, ByVal
targetPath As String) As Boolean- Try
- '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,
不是則添加- If Right(targetPath, 1) <> ""
Then targetPath += ""- '判斷目標(biāo)目錄是否存在,不存在則新建
- If Not Directory.Exists(targetPath)
Then Directory.CreateDirectory
(targetPath)- ' 得到源目錄的文件列表,該里面是包含
文件以及目錄路徑的一個(gè)數(shù)組- Dim fileList As String() =
Directory.GetFileSystemEntries
(sourcePath)- '遍歷所有的文件和目錄
- For Each filepath As String In
fileList- '目錄處理,遞歸
- If (Directory.Exists(filepath)) Then
- CopyDir(filepath, targetPath +
Path.GetFileName(filepath))- Else
VB.NET文件夾操作之復(fù)制文件
- File.Copy(filepath,
targetPath
+ Path.GetFileName
(filepath), True)- End If
- Next
- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
VB.NET文件夾操作之文件夾刪除
- Function DelDir()Function DelDir
(ByVal targetPath As String)
As Boolean- Try
- '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,
不是則添加- If Right(targetPath, 1) <> "
" Then targetPath += ""- '得到源目錄的文件列表,該里面是包
含文件以及目錄路徑的一個(gè)數(shù)組- Dim fileList As String() =
Directory.GetFileSystemEntries
(targetPath)- '遍歷所有的文件和目錄
- For Each filepath As String
In fileList- '目錄處理,遞歸
- If (Directory.Exists(filepath)) Then
- DelDir(targetPath + Path.GetFile
Name(filepath))- Else
- '刪除文件
- File.Delete(targetPath + Path.
GetFileName(filepath))- End If
- Next
- '刪除文件夾
- System.IO.Directory.Delete
(targetPath, True)- Return True
- Catch ex As Exception
- Return False
- End Try
- End Function
VB.NET文件夾操作的相關(guān)應(yīng)用方法就為大家介紹到這里。
新聞名稱:VB.NET文件夾操作相關(guān)技巧分享
文章位置:http://m.fisionsoft.com.cn/article/coiesoo.html


咨詢
建站咨詢
