PreserveN" /> PreserveN" /> PreserveN"/>

.NET Core SingleFile publish, get temp folder

37 Views Asked by At

i published my exe as Single file. And i included a file to my project:

    <ItemGroup>
       <None Update="python_base64.txt">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
          <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
       </None>
    </ItemGroup>

When i check AppData temp folder, i saw this: enter image description here

In this folder i have my python_base64.txt file(when i run published exe file). How can i access to that folder in my code?

Edit: i did this:

public static string GetTempFolder()
{
    string parentTemp = Path.GetTempPath() + ".net\\" + AppDomain.CurrentDomain.FriendlyName;
    string[] paths = Directory.GetDirectories(parentTemp);
    List<string> orderedPaths = paths.OrderByDescending(s => Directory.GetCreationTime(s)).ToList();
    return orderedPaths[0];
}
0

There are 0 best solutions below