1

I'm looking for files in c:\users\taras\documents\<folder> using Windows Search service (Provider=Search.CollatorDSO).
Output file path looks like this: C:\Users\taras\My Documents\<folder>\<some_path>. Now I need to get relative path , but first I have to normalize the path.

I tried do it like this:

string itemPath = new FileInfo(filePath).FullName;
string repoPath = new DirectoryInfo(repository).FullName;

But itemPath still have "My Documents" and repoPath still have "Documents".

Now I do it this way:

string itemPath = filePath.ToLower().Replace("\\my documents\\", "\\documents\\");
string repoPath = repository.ToLower().Replace("\\my documents\\", "\\documents\\");

It works but looks weird and doesn't help with similar other cases with Windows directories.

Is there any way to normalize the path (replace simlinks) before comparing?

Monika
  • 2,172
  • 15
  • 24
Taras Kozubski
  • 1,854
  • 1
  • 20
  • 33

0 Answers0