[C#] ActiveWorkspace.ConfigurationVariableValue() translates slash

It seems that ActiveWorkspace.ConfigurationVariableValue() translates / to \\ when returning the values of a variable. If I look in [Workspace - Configuration] the / is replaced with \. My string could contain either so I really need to get the original string (it's a password key). Is there any other way to get the original the value?

In the ucf-file: EAAAAMjKgUkIPwSmU/dpKk+pyvuYSxObomZLQN+NoYNkgLh1

In MicroStation: EAAAAMjKgUkIPwSmU\dpKk+pyvuYSxObomZLQN+NoYNkgLh1

In C#:           EAAAAMjKgUkIPwSmU\\dpKk+pyvuYSxObomZLQN+NoYNkgLh1

/Krister

  • hm,  a password in a cfg-file ? Even if it's a hashed value, I don't think that cfg's are made therefore (it is even not only a plain text file, but has to follow a syntax)

    What you are experiencing is a translation from the unix directory separator to the DOS/Windows one. This is still build in to prevent from escaped characters (like \n) and enable the use of such thinks like //servername... for UNC's, whereas it would be nec. to use \\\\servername otherwise to avoid problems with escaped chars.

    I fear you have to find another place for your password, and use the cfg only to provide a location to there.



    Answer Verified By: Krister Surell 

  • Krister,

    Michael is correct.  A MicroStation configuration file is not the best location to store special character data, but is a great facility to create and use values that are string parts that can be equated to either a file name, directory, or simple data type for display or interpretation.

    When config var "values" are read into MicroStation, MicroStation will convert any values containing "forwardslashes" to operating specific directory separators (e.g. For Windows a directory seperator is "\", not "/" that is preferred and used in MicroStation config files).  Caution is taken on our part a.) not to modify the original config file when doing so (in memory), and b.) process UNC mounts and URLs as expected.

    You have at least two choices available.  a.) you could use C# String.Replace() to safely replace the backslashes to forward slashes for your in memory copy of the original buffer, or b.) store data containing special characters in an alternate location.

    HTH,

    Bob



    Answer Verified By: Krister Surell 

  • For now a do a Replace but it seems that I need to move this to another file. Even though config files are mainly for path and settings it would still be nice to have an option if it should translate slashed or not.

    Regards,Krister

    Owner consultant at Surell Consulting AB