RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
VB.NET中怎么操作文件夹

这篇文章将为大家详细讲解有关VB.NET中怎么操作文件夹,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联是一家专注于成都网站设计、成都做网站与策划设计,安居网站建设哪家好?创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:安居等地区。安居做网站价格咨询:13518219792

VB.NET文件夹操作之文件夹复制

  1. Function CopyDir()Function CopyDir
    (ByVal sourcePath As String, ByVal 
    targetPath As String) As Boolean  

  2. Try  

  3. '检查目标目录是否以目录分割字符结束,
    不是则添加  

  4. If Right(targetPath, 1) <> ""
     Then targetPath += ""  

  5. '判断目标目录是否存在,不存在则新建  

  6. If Not Directory.Exists(targetPath)
     Then Directory.CreateDirectory
    (targetPath)  

  7. ' 得到源目录的文件列表,该里面是包含
    文件以及目录路径的一个数组  

  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文件夹操作之复制文件

  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. '检查目标目录是否以目录分割字符结束,
    不是则添加  

  4. If Right(targetPath, 1) <> "
    " Then targetPath += ""  

  5. '得到源目录的文件列表,该里面是包
    含文件以及目录路径的一个数组  

  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中怎么操作文件夹就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


当前题目:VB.NET中怎么操作文件夹
URL链接:http://sczitong.cn/article/jspsgi.html