1

I need help from someone someone smarter than I am to solve this puzzle.

I have a Registry branch that I want to convert into a file structure. Users make changes in the file structure, mostly because its easier for lusers to manipulate files. Then I can write those changes back to the registry. (I realize the risk here, please don't tell me that doing this is "bad", I know. This code is for a personal project and not going into any production models!)

So far my code works great:

Good Registry Values This translates great to: Good Explorer Values

However, since the registry is NOT a file structure, we can have "bad" keys such as:

Bad Key

This makes a file named Banana, in directory ...\Branch2\SubBranch1\Apple. Obviously. I thought about replacing the '\' with something, but what?

There is also an issue with ending a key or value with a '.' The file will not have the period.

Does anyone have a solution (or suggestion) to obtain the intended result?

Community
  • 1
  • 1
Tizz
  • 820
  • 1
  • 15
  • 31

2 Answers2

0

A simple character substitution map should accomodate you just fine.

backslash could be the arabic question mark: ؟ and slash could be the greek capital letter omega with dasia and prosgegrammeni: ᾩ

of course you would have to pick substitutions that were legal filesystem characters as well as characters that had a near zero chance of existing in a real registry key. But the unicode "alphabet" is quite large. Shouldnt be too much of a problem. The trailing period could be handled the same way.

charmap.exe is your friend

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
0

there is a couple of character that you need to handle /:?"<>| if the key value contain one of this character then you can't name your file with the same name as a key value i suggest you to use XML structure its very easy to maintain and manipulate

Amjad Abdelrahman
  • 3,372
  • 1
  • 13
  • 20