title: How do you access runfiles with Bazel 5.2.0 in c++
body: <p>Im trying to access runfiles within c++. Im using Bazel 5.2.0. I tried to access like this:</p>
  <pre><code>std::string error;
  std::unique_ptr&lt;Runfiles&gt; runfiles(Runfiles::Create(argv[0], &amp;error));
  if (!runfiles) {
      std::cerr &lt;&lt; error &lt;&lt; std::endl;
      return 1;
  }
  
  std::string path = runfiles-&gt;Rlocation(&quot;Test/Example.tx&quot;);
  std::cout &lt;&lt; &quot;Example.tx: &quot; &lt;&lt; path &lt;&lt; std::endl;
  
  std::ifstream in(path);
  
  if (!in.is_open())
  {
      std::cout &lt;&lt; &quot;Example.tx not found&quot; &lt;&lt; std::endl;
      return -1;
  }
  </code></pre>
  <p>(Example.tx is right, just to lazy to change)
  The program is finding a path but the path starts from the bazelisk directory and doesn't point to the binary dir.</p>
  <pre><code>Example.tx: C:\users\nikla\_bazel_nikla\d47dtf2d\execroot\__main__\bazel-out\x64_windows-fastbuild\bin\Test\Test.exe.runfiles/Test/Example.tx
  Example.tx not found
  </code></pre>
  <p>Im getting this as an result.
  Maybe there is a new way to access runfiles but Im not finding it.</p>