C:\Users\asus\source\repos\... etc?C:\Users\asus\source\repos\..., but if your installer hasn't created that exact file (and I doubt it's creating new users), then obviously that file won't existAppContext.BaseDirectory is the folder which contains your exe. So use Path.Join(AppContext.BaseDirectory, "Files", "Test1.pdf") etcAppContext.BaseDirectory. Write some code, see what paths it constructs (have a look in the debugger), and if it's not right keep fixing it until it worksdotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true -p:PublishSingleFile=true implies --self-contained true. Add --self-contained false to publish as runtime-dependent.-r RID and -p:PublishSingleFile=true can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish with the -r option for each RID.-p:IncludeNativeLibrariesForSelfExtract=true to include native libraries (like Common Language Runtime dlls) in the output executable, but be aware of drawbacks and consider using an installer framework instead of that property with PublishSingleFile.dotnet publishC:\Users\asus\source\repos\...C:\Users\asus\source\repos\...AppContext.BaseDirectoryAppContext.BaseDirectoryPath.Join(AppContext.BaseDirectory, "Files", "Test1.pdf")dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true-p:PublishSingleFile=true-p:PublishSingleFile=true--self-contained true--self-contained false-r RIDdotnet publishdotnet publish-r-p:IncludeNativeLibrariesForSelfExtract=true<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>