ファイルが存在してなくてもエラーにならない方法
Dim sFilePath As String = "C:\work\myfile.txt"
System.IO.File.Delete(sFilePath)
Dim sFilePath As String = "C:\work\myfile.txt"
System.IO.File.Delete(sFilePath)
Dim sFilePath As String = "C:\work\myfile.txt"
Dim finfo As New System.IO.FileInfo(sFilePath)
finfo.Delete()
Dim sFilePath As String = "C:\work\myfile.txt"
Dim finfo As New System.IO.FileInfo(sFilePath)
finfo.Delete()
ファイルが無いとエラーを発生する方法
- FileSystem.DeleteFile メソッドを使用する方法
Dim sFilePath As String = "C:\work\myfile.txt"
My.Computer.FileSystem.DeleteFile(sFilePath)
Dim sFilePath As String = "C:\work\myfile.txt"
My.Computer.FileSystem.DeleteFile(sFilePath)