VB.NETに指定ファイルが存在の判定

2021年9月15日

書式
Public Shared Function Exists (path As String) As Boolean
指定したファイルが存在するかどうかを確認します。
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Imports System.IO
Module Module1
Sub Main()
'ファイル文字列の宣言
Dim srcFile As String = "C:\\data\\test_2022oly.doc"
If File.Exists(srcFile) Then
Console.WriteLine("ファイルが存在します")
End If
Console.ReadKey()
End Sub
End Module
Imports System.IO Module Module1 Sub Main() 'ファイル文字列の宣言 Dim srcFile As String = "C:\\data\\test_2022oly.doc" If File.Exists(srcFile) Then Console.WriteLine("ファイルが存在します") End If Console.ReadKey() End Sub End Module
Imports System.IO

Module Module1

    Sub Main()


        'ファイル文字列の宣言
        Dim srcFile As String = "C:\\data\\test_2022oly.doc"

        If File.Exists(srcFile) Then
            Console.WriteLine("ファイルが存在します")
        End If

        Console.ReadKey()

    End Sub

End Module

 

VB.net

Posted by arkgame