I am currently saving filepaths to a subkey in the Windows Registry like this:
Registry.SetValue(String.Format("HKEY_CURRENT_USER\Software\MyApp\{0}\{1}\{2}\{3}", FilePath.Replace("\", "/"), x, y, z), SettingName, SettingValue)
Since the Windows Registry doesn’t accept the char \ in the sub-key name, I am replacing it with /.
So I was wondering if this is okay and if there are any other characters that a file name can have but a subkey name cannot have?
Backslash is the only character not allowed. See this post
To answer your implied question as to whether this is OK: it might be more elegant to store the whole file path as a string value in a key. If you have a need to represent the file structure in the key name itself then your approach is probably the cleanest.