偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

教你更快速使用VB.NET文件夾操作

開發(fā) 后端
本文主要就VB.NET文件夾操作進行代碼詳細(xì)演示,讓你更輕松的運用,代碼只要復(fù)雜粘貼到機器上就可以跑起來用,但是還是希望大家看懂下面的代碼。

文件夾這個概念大家都很熟悉,在各各操作系統(tǒng)中都有文件夾這個概念,而在VB.NET這門開發(fā)語言中如何更好更安全的操作文件夾,這就是今天我們要來演示的一個案例。希望從VB.NET文件夾操作這個案例中學(xué)到技巧。

VB.NET文件夾操作代碼:

  1. '文件夾復(fù)制  
  2. Function CopyDir()Function CopyDir(ByVal sourcePath As String, ByVal targetPath As String) As Boolean  
  3. Try  
  4. '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,不是則添加  
  5. If Right(targetPath, 1) <> "" Then targetPath += ""  
  6. '判斷目標(biāo)目錄是否存在,不存在則新建  
  7. If Not Directory.Exists(targetPath) Then Directory.CreateDirectory(targetPath)  
  8. ' 得到源目錄的文件列表,該里面是包含文件以及目錄路徑的一個數(shù)組  
  9. Dim fileList As String() = Directory.GetFileSystemEntries(sourcePath)  
  10. '遍歷所有的文件和目錄  
  11. For Each filepath As String In fileList  
  12. '目錄處理,遞歸  
  13. If (Directory.Exists(filepath)) Then  
  14. CopyDir(filepath, targetPath + Path.GetFileName(filepath))  
  15. Else  
  16. '復(fù)制文件  
  17. File.Copy(filepath, targetPath + Path.GetFileName(filepath), True)  
  18. End If  
  19. Next  
  20. Return True  
  21. Catch ex As Exception  
  22. Return False  
  23. End Try  
  24. End Function  
  25. '文件夾刪除  
  26. Function DelDir()Function DelDir(ByVal targetPath As String) As Boolean  
  27. Try  
  28. '檢查目標(biāo)目錄是否以目錄分割字符結(jié)束,不是則添加  
  29. If Right(targetPath, 1) <> "" Then targetPath += ""  
  30. '得到源目錄的文件列表,該里面是包含文件以及目錄路徑的一個數(shù)組  
  31. Dim fileList As String() = Directory.GetFileSystemEntries(targetPath)  
  32. '遍歷所有的文件和目錄  
  33. For Each filepath As String In fileList  
  34. '目錄處理,遞歸  
  35. If (Directory.Exists(filepath)) Then  
  36. DelDir(targetPath + Path.GetFileName(filepath))  
  37. Else  
  38. '刪除文件  
  39. File.Delete(targetPath + Path.GetFileName(filepath))  
  40. End If  
  41. Next  
  42. '刪除文件夾  
  43. System.IO.Directory.Delete(targetPath, True)  
  44. Return True  
  45. Catch ex As Exception  
  46. Return False  
  47. End Try  
  48. End Function 

以上就是我為大家提高的關(guān)于VB.NET文件夾操作的一個案例,大家快試試吧!

【編輯推薦】

  1. 實例講述VB.NET使用Log4Net
  2. 三分鐘學(xué)會VB.NET轉(zhuǎn)換形態(tài)
  3. VB.NET獲取硬盤信息四大法寶
  4. 講述VB.NET調(diào)用Excel的好處
  5. 簡單例子概述VB.NET新窗體
責(zé)任編輯:田樹 來源: 博客
相關(guān)推薦

2010-01-13 10:25:30

VB.NET文件夾操作

2010-01-21 13:34:56

VB.NET刪除文件夾

2010-01-12 09:51:07

VB.NET操作dbf

2009-10-27 08:56:22

VB.NET文件夾

2010-01-11 14:28:14

VB.NET操作Exc

2009-10-27 17:59:16

VB.NET刪除文件夾

2009-11-02 12:35:10

VB.NET追加文件

2009-10-27 16:05:52

VB.NET File

2009-11-02 13:54:27

VB.NET shel

2009-10-29 14:16:32

VB.NET讀寫文本文

2009-11-02 17:54:44

VB.NET數(shù)組

2009-10-21 09:40:23

VB.NET搜索

2009-11-02 15:49:23

VB.NET顯示系統(tǒng)信

2009-11-02 11:02:58

VB.NET XML文

2009-11-10 11:30:12

VB.NET循環(huán)語句

2009-10-09 16:11:33

VB.NET語法

2009-10-28 13:24:25

VB.NET文件

2010-01-15 19:04:09

2009-10-29 15:28:38

VB.NET文件操作

2009-11-10 15:18:35

VB.NET封面
點贊
收藏

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