如何检查文件是否是.exe

时间:2017-09-06 15:10:50

标签: vb.net

我想知道是否有人知道我怎么能做像

这样的事情
if file.Exists("file path") 
   then message box.show("exists") 
else file.delete

我可以做类似的事情但要检查文件是否是可执行文件,是否执行命令以及是否不执行其他命令?提前谢谢。

2 个答案:

答案 0 :(得分:0)

你需要这样的foreach。

For Each file As String In
My.Computer.FileSystem.GetFiles("C:\folder")
    Dim extention As String =
    System.IO.Path.GetExtension(file)
    MsgBox("The file extension is " & extention)
Next

检查扩展名是否类似.exe

答案 1 :(得分:0)

Dim filepath as string = ""
 If filepath.EndsWith(".exe") then
 //do something
 Else
 //do something else
 End if
相关问题