mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace Remotely_Server.API
|
|
{
|
|
[Route("api/[controller]")]
|
|
public class ScreenCastVersionController : Controller
|
|
{
|
|
public ScreenCastVersionController(IHostingEnvironment hostingEnv)
|
|
{
|
|
this.HostingEnv = hostingEnv;
|
|
}
|
|
|
|
public IHostingEnvironment HostingEnv { get; }
|
|
|
|
// GET: api/<controller>
|
|
[HttpGet("{platform}")]
|
|
public string Get(string platform)
|
|
{
|
|
string ext = "";
|
|
|
|
switch (platform)
|
|
{
|
|
case "Windows":
|
|
ext = "exe";
|
|
break;
|
|
case "Linux":
|
|
ext = "appimage";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
var filePath = Path.Combine(HostingEnv.WebRootPath, "Downloads", $"Remotely_ScreenCast.{ext}");
|
|
if (!System.IO.File.Exists(filePath))
|
|
{
|
|
return "0.0.0.0";
|
|
}
|
|
var version = FileVersionInfo.GetVersionInfo(filePath);
|
|
return version.FileVersion.ToString();
|
|
}
|
|
}
|
|
}
|