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

成都創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務領(lǐng)域包括:成都網(wǎng)站設計、成都網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的保靖網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!
VB.NET文件夾操作之文件夾復制
- Function CopyDir()Function CopyDir
(ByVal sourcePath As String, ByVal
targetPath As String) As Boolean- Try
- '檢查目標目錄是否以目錄分割字符結(jié)束,
不是則添加- If Right(targetPath, 1) <> ""
Then targetPath += ""- '判斷目標目錄是否存在,不存在則新建
- If Not Directory.Exists(targetPath)
Then Directory.CreateDirectory
(targetPath)- ' 得到源目錄的文件列表,該里面是包含
文件以及目錄路徑的一個數(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文件夾操作之復制文件
- 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
- '檢查目標目錄是否以目錄分割字符結(jié)束,
不是則添加- If Right(targetPath, 1) <> "
" Then targetPath += ""- '得到源目錄的文件列表,該里面是包
含文件以及目錄路徑的一個數(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)應用方法就為大家介紹到這里。
網(wǎng)站名稱:VB.NET文件夾操作相關(guān)技巧分享
轉(zhuǎn)載注明:http://m.5511xx.com/article/coiesoo.html


咨詢
建站咨詢
