1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2024-09-16 05:30:09 +00:00
MpcNET/LibMpcTest/MpdServerTest.cs

47 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.IO;
namespace LibMpcTest
{
2016-12-13 12:12:51 +00:00
public class MpdServerTest : IDisposable
{
public MpdServerTest()
{
var serverPath = Path.Combine(AppContext.BaseDirectory, "Server");
MpdConf.Create(serverPath);
var mpdExePath = Path.Combine(serverPath, "mpd.exe");
var mpdConfPath = Path.Combine(serverPath, "mpd.conf");
2016-12-13 12:12:51 +00:00
Process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = mpdExePath,
WorkingDirectory = serverPath,
Arguments = string.Join(" ", mpdConfPath, "-v"),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
}
};
2016-12-13 12:12:51 +00:00
Process.Start();
LogOutput = Process.StandardOutput.ReadToEnd();
LogError = Process.StandardError.ReadToEnd();
}
2016-12-13 12:12:51 +00:00
public Process Process { get; }
public string LogError { get; }
public string LogOutput { get; }
public void Dispose()
{
2016-12-13 12:12:51 +00:00
Process?.Kill();
Process?.Dispose();
}
}
}