以下の内容はhttps://blog.systemjp.net/entry/2021/11/10/104242より取得しました。


VB.NETでファイルを削除する方法色々

ファイルが存在してなくてもエラーにならない方法

  • File.Delete メソッドを使用する方法
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)

  • FileInfo クラスを使用する方法
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)

ネタ元

note.websmil.com




以上の内容はhttps://blog.systemjp.net/entry/2021/11/10/104242より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14