1、判断文件/目录是否存在

        Try
' 先判断文件是否存在。
If Not File.Exists(TextBox4.Text) Then
File.CreateText(TextBox4.Text) '单纯创建文件一般不常用,正常情况下是创建文件然后进行读写操作
'System.IO.File.Create(TextBox4.Text)
End If Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try
        Try
' 先建立目录以便用于后续的删除示范。
' If Not Directory.Exists("D:\网易") Then
If Not Directory.Exists(TextBox5.Text) Then
Directory.CreateDirectory(TextBox5.Text) '如果目录不存在则创建目录
End If ' 启动 Windows 资源管理器。
Process.Start("explorer.exe", TextBox5.Text) Catch ex As Exception
MessageBox.Show(ex.Message)
Exit Sub
End Try

2、创建、复制、移动、删除文件

2.1 获取文件信息(创建时间) FileDateTime(fii(i).FullName)     File.GetCreationTime(path)

 System.IO.File.Create(Path)'创建文件
System.IO.File.CreateText(Path)'创建文件
System.IO.File.Copy(Path,targetPath) '复制到新位置,不允许覆盖现有文件 也可以'FileCopy(TextBox4.Text, "C:" & "\" & file_name(UBound(file_name)))
System.IO.File.Move(SourceFileName, DestFileName)
System.IO.File.Delete(Path) '追加
System.IO.File.AppendText
'替换
System.IO.File.Replace
3、创建、移动、删除目录
        Directory.CreateDirectory(Path) '创建目录
Directory.Move(str1, str2)'移动目录
Directory.Delete(Path)'删除目录

更多操作可以查看(VS支持自动补全功能挺好的)

System.IO之File

https://msdn.microsoft.com/zh-cn/library/system.io.file(v=vs.110).aspx

https://blog.csdn.net/G00d_Boy/article/details/81627647


 

最新文章

  1. 【二分】POJ 2109
  2. Socket之TCP连接_TcpNoDelay
  3. ToolBar 修改边距
  4. centos could not retrieve mirrorlist
  5. 查看sqlserver默认的编码格式
  6. 如何在jQuery中使用 setInterval,setTimeout
  7. Eclipse servlet和jsp编写
  8. java.lang.IllegalStateException: ActionBarImpl can only be used with a compatible window decor layou
  9. 打造属于自己的支持版本迭代的Asp.Net Web Api Route
  10. CSS :befor :after 伪元素的妙用
  11. 网络流 P2770 航空路线问题
  12. 小程序 movable-view 在页面中的可移动图标
  13. .Net Core 项目中添加统一的XSS攻击防御过滤器
  14. Python学习-字符编码浅析
  15. oracle 文件系统
  16. 【转】C# Async/Await 异步编程中的最佳做法
  17. CNN中tensorboard数据可视化
  18. appium定位安装包启动类名称
  19. 20155213 2016-2017-2《Java程序设计》课程总结
  20. 网络编程----粘包以及粘包问题的解决、FTP上传

热门文章

  1. jquery mouseenter()方法 语法
  2. js的三种异步处理
  3. C Vus the Cossack and Strings ( 异或 思维)
  4. hdu 5733 tetrahedron 四面体内切球球心公式
  5. Java集成POI进行Excele的导入导出,以及报错: java.lang.AbstractMethodError..........
  6. leetcode题目11.盛最多水的容器(中等)
  7. (十一)C语言之选择结构
  8. 2018-2019-20175329 实验三敏捷开发与XP实践《Java开发环境的熟悉》实验报告
  9. php phpexcel 创建excel
  10. OpenCV学习笔记(12)——OpenCV中的轮廓