title: In VStudio 2019, VB, .NET-5: for a ClickOnce installed app, how do I locate the application's data directory at runtime?
body: <p>My VStudio is 2019 Community, the application is an old VB Windows/Forms app being brought forward from .Net-3.5-ish to .Net-5.</p>
  <p>Under .Net-4.8 or earlier, using the namespace System.Deployment.Application, one could access <code>ApplicationDeployment.DataDirectory </code>to locate that artificially-generated directory in <code>\Users\Username\AppData\Local\Apps\2.0\...</code> that a 1-click installation would create and populate with data files from the Project Build/Publish.</p>
  <p>Under .Net-5, I believe that particular set of functions has been taken out - yet the ClickOnce installer still places Data files there. How do I programmatically locate that directory? The Application Path can be located from <code>System.AppContext.BaseDirectory</code>, but that doesn't help in locating the data.</p>
  <p>This app, an old bit of VB code, has a large number of application data files that need to be installed along with the code. As there are more than 40 of them, we've kept them in their own <code>\Data</code> directory, which is included in the Project, is under Git control to keep their versions aligned with their code...</p>
  <p>In an uninstalled app, we could keep this \Data directory adjacent to the executable, and find it easily at runtime: but with a ClickOnce installed app, that falls apart. In the Publish configuration, all the data files are identified, with Group=Required, Publish Status=DataFile.</p>
  <p>Can I either:</p>
  <ol>
  <li><p>Easily configure the 1-click installer to place our \Data directory and its contents into one of the standard \Local\Appname or \Roaming\Appname directories that seem to also get created, but left empty? Those can easily be located at runtime.</p>
  </li>
  <li><p>Easily construct at runtime the path to that obscure data directory that 1-click normally creates and uses for data?</p>
  </li>
  </ol>
  <p>Cheers, and Thanks! Bob</p>