目的是利用 VB.net / C# 来检查文件是否存在。

VB代码

需要引入 Imports System.IO 和 Imports System

1
2
Dim curFile As String = "c:\temp\test.txt"
MessageBox.Show(If(File.Exists(curFile), "File exists.", "File does not exist."))

C#代码

需要引入 using System.IO;

1
2
string curFile = @"c:\temp\test.txt";
MessageBox.Show(File.Exists(curFile) ? "File exists." : "File does not exist.");