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

VB.NET文件夾操作相關(guān)技巧分享

開發(fā) 后端
我們在這里為大家?guī)淼挠嘘P(guān)VB.NET文件夾操作的具體方法主要分為對文件夾的復(fù)制以及刪除這兩種,希望能對又需要的朋友有所幫助。

編程人員利用VB.NET進(jìn)行實際編程,可以輕松簡便的完成各種功能。比如今天為大家介紹的VB.NET在對文件夾的操作上,就可以輕松的實現(xiàn)各種操作。下面就讓我們一起來看看VB.NET文件夾操作相關(guān)應(yīng)用技巧。

VB.NET文件夾操作之文件夾復(fù)制

  1. Function CopyDir()Function CopyDir
    (ByVal sourcePath As String, ByVal 
    targetPath As String) As Boolean  
  2. Try  
  3. '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,
    不是則添加  
  4. If Right(targetPath, 1) <> ""
     Then targetPath += ""  
  5. '判斷目標(biāo)目錄是否存在,不存在則新建  
  6. If Not Directory.Exists(targetPath)
     Then Directory.CreateDirectory
    (targetPath)  
  7. ' 得到源目錄的文件列表,該里面是包含
    文件以及目錄路徑的一個數(shù)組  
  8. Dim fileList As String() = 
    Directory.GetFileSystemEntries
    (sourcePath)  
  9. '遍歷所有的文件和目錄  
  10. For Each filepath As String In 
    fileList  
  11. '目錄處理,遞歸  
  12. If (Directory.Exists(filepath)) Then  
  13. CopyDir(filepath, targetPath + 
    Path.GetFileName(filepath))  
  14. Else 

VB.NET文件夾操作之復(fù)制文件

  1. File.Copy(filepath, 
    targetPath 
    + Path.GetFileName
    (filepath), True)  
  2. End If  
  3. Next  
  4. Return True  
  5. Catch ex As Exception  
  6. Return False  
  7. End Try  
  8. End Function 

VB.NET文件夾操作之文件夾刪除

  1. Function DelDir()Function DelDir
    (ByVal targetPath As String) 
    As Boolean  
  2. Try  
  3. '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,
    不是則添加  
  4. If Right(targetPath, 1) <> "
    " Then targetPath += ""  
  5. '得到源目錄的文件列表,該里面是包
    含文件以及目錄路徑的一個數(shù)組  
  6. Dim fileList As String() = 
    Directory.GetFileSystemEntries
    (targetPath)  
  7. '遍歷所有的文件和目錄  
  8. For Each filepath As String 
    In fileList  
  9. '目錄處理,遞歸  
  10. If (Directory.Exists(filepath)) Then  
  11. DelDir(targetPath + Path.GetFile
    Name(filepath))  
  12. Else  
  13. '刪除文件  
  14. File.Delete(targetPath + Path.
    GetFileName(filepath))  
  15. End If  
  16. Next  
  17. '刪除文件夾  
  18. System.IO.Directory.Delete
    (targetPath, True)  
  19. Return True  
  20. Catch ex As Exception  
  21. Return False  
  22. End Try  
  23. End Function 

VB.NET文件夾操作的相關(guān)應(yīng)用方法就為大家介紹到這里。

【編輯推薦】

  1. VB.NET StringWriter基礎(chǔ)概念詳解
  2. VB.NET ArrayList具體功能詳解
  3. VB.NET窗體打印代碼解讀
  4. VB.NET Format函數(shù)基礎(chǔ)應(yīng)用技巧詳解
  5. VB.NET StructLayout特點詳解
責(zé)任編輯:曹凱 來源: CSDN
相關(guān)推薦

2010-01-15 19:04:09

2010-01-13 15:33:40

VB.NET菜單項目

2010-01-14 16:04:32

VB.NET顯示時間

2009-10-27 11:03:16

VB.NET文件夾操作

2010-01-15 15:10:43

VB.NET Stri

2010-01-18 16:33:57

VB.NET加密文件

2010-01-07 13:40:50

VB.NET讀取XML

2010-01-21 13:34:56

VB.NET刪除文件夾

2010-01-08 10:09:50

VB.NET注冊表操作

2010-01-07 10:02:53

Flash控制VB.N

2010-01-07 15:29:59

VB.NET表達(dá)式

2010-01-15 18:01:05

VB.NET結(jié)構(gòu)化異常

2009-10-27 08:56:22

VB.NET文件夾

2010-01-15 13:52:42

VB.NET屬性設(shè)置

2010-01-18 18:50:26

VB.NET鼠標(biāo)手勢

2009-10-27 17:59:16

VB.NET刪除文件夾

2010-01-22 11:02:30

VB.NET創(chuàng)建新變量

2010-01-13 15:52:59

VB.NET浮動窗體

2010-01-18 14:08:29

VB.NET類型轉(zhuǎn)換

2010-01-07 17:24:12

VB.NET連接數(shù)據(jù)庫
點贊
收藏

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