Wow! Where did you get that string from?
I couldn't find anything in the framework that could help optimize this file
name, so I wrote one by myself
Here it is...
static string OptimizeFilePath(string filePath)
{
string[] parts =
filePath.Split(System.IO.Path.DirectorySeparatorCh ar,
System.IO.Path.DirectorySeparatorChar);
Stack stack = new Stack();
foreach (string folder in parts)
{
if (folder == "" || folder == ".")
continue;
if (folder == "..")
stack.Pop();
else
stack.Push(folder);
}
StringBuilder optimizedPath = new StringBuilder();
foreach (string folder in stack)
{
optimizedPath.Insert(0, folder);
optimizedPath.Insert(0,
System.IO.Path.DirectorySeparatorChar);
}
optimizedPath.Remove(0, 1);
return optimizedPath.ToString();
}
--
HTH
Stoitcho Goutsev (100)
<sh********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi All,
I call Assembly.LoadFrom("C:\\MyDir\\MyAssembly.dll")- it works fine.
However when I call the following, it fails:
Assembly.LoadFrom("C:\\MyDir\\..\\MyDir\\..\\MyDir \\..\\MyDir\\..\\MyDir\\..\\MyDir\\
..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\My Dir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\. .\\
MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\ \..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\
MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\ \..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\MyDir\\..\\
MyDir\\..\\MyDir\\MyAssembly.dll")
Can someone tell me how can I get rid of it. Is there a way I can
compact the path before I pass it on to LoadFrom(string path).
Thanks,
Shrish