tft每日頭條

 > 科技

 > netcore工程部署

netcore工程部署

科技 更新时间:2024-07-18 23:26:10

netcore工程部署?NetCore 打開指定文件 /// <summary>,接下來我們就來聊聊關于netcore工程部署?以下内容大家不妨參考一二希望能幫到您!

netcore工程部署(Netcore打開指定文件)1

netcore工程部署

NetCore 打開指定文件

/// <summary>

/// 打開指定目錄下的文件

/// </summary>

/// <param name="filePath">文件地址(包含文件名稱)</param>

/// <returns></returns>

public static bool OpenFile(string filePath)

{

try

{

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) //windows環境下打開文件

{

filePath = filePath.Replace("&", "^&");

Process.Start(new ProcessStartInfo("cmd", $"/c start {filePath}") { CreateNoWindow = true });

}

else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) //Linux環境下打開文件

{

Process.Start("xdg-open", filePath);

}

else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) //Mac環境下打開文件

{

Process.Start("open", filePath);

}

}

catch (Exception ex)

{

return false;

}

return true;

}

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved