Error on Path.GetDirectoryName

ryanlcs

Member
Joined
Apr 17, 2008
Messages
12
Programming Experience
Beginner
I have this code in which it will retrieve a path from registry.

VB.NET:
Dim pRegKey As RegistryKey = Registry.LocalMachine
pRegKey = pRegKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\File Processing Failure Alert")
strExePath = pRegKey.GetValue("ImagePath")

The values returned is
"C:\APP\KMSAPP02 TestDB File Processing Failure Alert (2nd version)\bin\KMSAPP02 TestDB File Processing Failure Alert.exe".

And I have check on registry that the value is true.

But when come this this statement,

VB.NET:
PathML = Path.GetDirectoryName(strExePath)

it saids that there is a "Illegal characters in path".

If I change the statement to below, somehow it works:

VB.NET:
strExePath = "C:\APP\KMSAPP02 TestDB File Processing Failure Alert (2nd version)\bin\KMSAPP02 TestDB File Processing Failure Alert.exe"

PathML = Path.GetDirectoryName(strExePath)

Any ideas how this happen?

To clarify:

Failed statement:
But value returned from pRegKey.GetValue("ImagePath") is
"C:\APP\KMSAPP02 TestDB File Processing Failure Alert (2nd version)\bin\KMSAPP02 TestDB File Processing Failure Alert.exe"

VB.NET:
strExePath = pRegKey.GetValue("ImagePath")
PathML = Path.GetDirectoryName(strExePath)

Successed statement:

VB.NET:
strExePath = "C:\APP\KMSAPP02 TestDB File Processing Failure Alert (2nd version)\bin\KMSAPP02 TestDB File Processing Failure Alert.exe"
PathML = Path.GetDirectoryName(strExePath)
 
Back
Top