SokomoKud SokomoKud - 2 months ago 10
Vb.net Question

File.Exists always returning true even when file doesn't exist

Before the question, sorry for my english, is not my native language.

I think the title explain itself, I'm trying to know if the User PC has a dll in system32 folder, but even if I move the .dll to desktop(for test purpose) the File.Exists return True.

The code I'm using:

Imports System.IO
Public sys32Path As String = "C:\Windows\System32\"

If File.Exists(sys32Path + "d3dx9_42.dll") = True Then
ListBox1.Refresh()
ListBox1.Items.Add(sys32Path + "d3dx9_42.dll | Found !")
fstDLL = True

ElseIf File.Exists(sys32Path + "d3dx9_42.dll") = False Then
ListBox1.Refresh()
ListBox1.Items.Add("d3dx9_42.dll | Missing !")
fstDLL = False
End If

Answer

Keep in mind that if you run a 32-bit application on a 64-bit system then file system redirection causes C:\Windows\System32 to be redirected to C:\Windows\SysWOW64 which is the "System32" folder for 32-bit apps.

If you want to access the actual System32 folder then you could either:

Comments