title: Directory.SetCurrentDirectory throws PathTooLongException
body: <p>There are several related questions on stackoverflow but either my situation is different or I am too dumb to relate those to situation. I am hoping someone can help me with this. Further I am not even much of a .NET developer so I apologize in advance for any wrong terminology use.</p>
  
  <p>My scenario is as follows: The tool that is used to deploy our .net application (One Click?) puts it in a directory whose full name exceeds 300 characters. The application uses a third party component -- lets call it dbstore -- that processes the specified file that resides in the application deployment directory. </p>
  
  <p>So far we were using <code>Assembly.GetExecutingAssembly().GetName().CodeBase</code> to construct the fully qualified name of the file to pass to dbstore. But dbstore uses old style APIs and fails when it tries to open the file. </p>
  
  <p>Since dbstore is not expected to change soon, it was recommended that the application chdir to the deployment directory and pass a relative path name in current directory to it. This is also the approach described in the accepted response <a href="https://stackoverflow.com/questions/1087565/pathtoolongexception-in-c-code/1087612#1087612">PathTooLongException in C# code</a></p>
  
  <p>However I find that <code>Directory.SetCurrentDirectory</code> also throws <code>PathTooLongException</code>. This happens even when I am using UNC path name, e.g a name starting with <code>\\?\0000000000000\...</code></p>
  
  <p>Am I doing something fundamentally wrong? Is there another function to use? </p>
  
  <p>EDIT: It seems there is no way to achieve what I am looking for. Far as I can tell there is no way to set current directory to a long path. </p>