.net core 如何在.NET核心项目的launchSettings.json中使用相对路径?
My launchSettings.json文件:.net core 如何在.NET核心项目的launchSettings.json中使用相对路径?,.net-core,.net Core,My launchSettings.json文件: { “概况”:{ “WinRedismProxy”:{ “命令名”:“可执行文件”, “executablePath”:“C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe”, “commandLineArgs:“dotnet C:\\Users\\KudeBJ\\Desktop\\redis smc proxy prototype\\WinRedismProxy\\Wi
{
“概况”:{
“WinRedismProxy”:{
“命令名”:“可执行文件”,
“executablePath”:“C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe”,
“commandLineArgs:“dotnet C:\\Users\\KudeBJ\\Desktop\\redis smc proxy prototype\\WinRedismProxy\\WinRedismProxy\\bin\\Debug\\netcoreapp3.0\\WinRedismProxy.dll”
}
}
}
上面的代码中有一个问题。将项目放置在其他位置而不是桌面时,项目将不会运行。这是因为我在配置中使用了绝对路径。有没有办法将其更改为相对的?您可以使用:
var path=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
它将获得
C:\\Users\\KudeBJ\\AppData\\Roaming
文件夹。此外,您还可以获得其他文件夹。查看Environment.SpecialFolder
enum.您想要实现什么?是否要求应用程序在PowerShell中打开?@StephenKennedy我想使用PowerShell来执行我的应用程序,而不是cmd。谢谢~我得到了路径,但有点困惑,如何将路径写入json文件?