I need to replace the end of a pathfile in VB. So I try this code :
Private Function getfiledata(ByVal fichier As String) As String
Dim fileReader As String
Dim FichierFinal As String
MsgBox(fichier)
FichierFinal = fichier.Replace("E002.pfx","_E002.pem")
FichierFinal = fichier.Replace("X002.pfx","_X002.pem")
FichierFinal = fichier.Replace("A005.pfx","_A005.pem")
MsgBox(FichierFinal)
fileReader = My.Computer.FileSystem.ReadAllText(FichierFinal)
Return fileReader
End Function
The first MsgBox function return me the following result :
C:/Users/Bruno/Documents/Visual Studio 2010/Projects/SerEbics/SerEbics/bin/Debug/Certificats/512250X002.pfx
But the second return me the same path :
C:/Users/Bruno/Documents/Visual Studio2010/Projects/SerEbics/SerEbics/bin/Debug/Certificats/512250X002.pfx
So I need this result :
C:/Users/Bruno/Documents/Visual Studio2010/Projects/SerEbics/SerEbics/bin/Debug/Certificats/512250_X002.pem
Thank you in advance !
Thomas
Replacemakes the change you want, but the third one overwrites the result of the second. I think you intended the second and thirdReplacestatements to beFichierFinal = FichierFinal.Replace("X002.pfx","_X002.pem")andFichierFinal = FichierFinal.Replace("A005.pfx","_A005.pem"). - Blackwood