CodeLiturgy.Dashboard/BlueWest/Core/Tools/AssemblyUtils.cs

37 lines
1.0 KiB
C#
Raw Normal View History

2021-12-06 02:49:27 +03:00
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace BlueWest.Tools
{
public static class AssemblyUtils
{
public static double GetProcessMemory()
{
var memory = 0.0;
using (Process proc = Process.GetCurrentProcess())
{
// The proc.PrivateMemorySize64 will returns the private memory usage in byte.
// Would like to Convert it to Megabyte? divide it by 2^20
memory = proc.PrivateMemorySize64 / (1024*1024);
}
return memory;
}
public static string GetAssemblyPath()
{
var assemblyName = GetAssemblyLocation();
var directory = Path.GetDirectoryName(assemblyName);
return directory;
}
private static string GetAssemblyLocation()
{
var assembly = Assembly.GetEntryAssembly();
var assemblyName = assembly.Location;
return assemblyName;
}
}
}