如何使用VB.NET文件夹操作
发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,小编给大家分享一下如何使用VB.NET文件夹操作,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!VB.NET文件夹操作代码:'文件夹复制 Function CopyDir()Func
千家信息网最后更新 2024年10月01日如何使用VB.NET文件夹操作
小编给大家分享一下如何使用VB.NET文件夹操作,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
VB.NET文件夹操作代码:
'文件夹复制 Function CopyDir()Function CopyDir(ByVal sourcePath As String, ByVal targetPath As String) As Boolean Try '检查目标目录是否以目录分割字符结束,不是则添加 If Right(targetPath, 1) <> "" Then targetPath += "" '判断目标目录是否存在,不存在则新建 If Not Directory.Exists(targetPath) Then Directory.CreateDirectory(targetPath) ' 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组 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 '复制文件 File.Copy(filepath, targetPath + Path.GetFileName(filepath), True) End If Next Return True Catch ex As Exception Return False End Try End Function '文件夹删除 Function DelDir()Function DelDir(ByVal targetPath As String) As Boolean Try '检查目标目录是否以目录分割字符结束,不是则添加 If Right(targetPath, 1) <> "" Then targetPath += "" '得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组 Dim fileList As String() = Directory.GetFileSystemEntries(targetPath) '遍历所有的文件和目录 For Each filepath As String In fileList '目录处理,递归 If (Directory.Exists(filepath)) Then DelDir(targetPath + Path.GetFileName(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文件夹操作"有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!
文件
目录
文件夹
目标
字符
数组
源目录
篇文章
路径
递归
处理
检查
代码
完了
更多
知识
行业
资讯
资讯频道
频道
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
用友t6数据库安装方法
韶关网络安全实战特训营攻防技术
网络安全法从哪年实行
数据库应用技术第一章作业
c 数据库连接池 事务
软件开发成本评估联盟
首都网络安全日的口号是
项目管理服务器挑选
第三届反恐与网络安全治理
德阳软件开发解决方案
广东易双网络技术有限公司
软件开发公司市场前景
数据库安全入门
存储阵列 数据库
工控软件开发怎么收费
电子软件开发学校学费
移动的网络技术做什么的
什么是令牌计算机网络技术
济南智能软件开发流程
手机应用软件开发注意事项
永服务器
一个官网的云服务器要多少一年
免费加油卡软件开发旅游卡
数据库做多可以存多少字节
数据库实用工具中文最新版
项目管理服务器挑选
优圣网络技术
支持256g内存的服务器主板
FAERS数据库分析
软件开发过程乌龟图