Remotely/Remotely_Server/API/CoreVersionController.cs
2021-07-29 07:53:46 -07:00

33 lines
849 B
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
namespace Remotely_Server.API
{
[Route("api/[controller]")]
public class CoreVersionController : Controller
{
public CoreVersionController(IHostingEnvironment hostingEnv)
{
this.HostingEnv = hostingEnv;
}
public IHostingEnvironment HostingEnv { get; }
// GET: api/<controller>
[HttpGet()]
public string Get()
{
var filePath = Path.Combine(HostingEnv.ContentRootPath, "CurrentAgentVersion.txt");
if (!System.IO.File.Exists(filePath))
{
return "0.0.0.0";
}
return System.IO.File.ReadAllText(filePath).Trim();
}
}
}