using System;
using System.IO;
namespace FSI.Lib.CompareNetObjects
{
///
/// Helper methods for files and directories
///
public static class FileHelper
{
///
/// Get the current directory of the executing assembly
///
///
public static string GetCurrentDirectory()
{
#if NETSTANDARD
string basePath = AppContext.BaseDirectory;
#else
string basePath = AppDomain.CurrentDomain.BaseDirectory;
#endif
return PathSlash(basePath);
}
///
/// Ensure the passed string ends with a directory separator character unless the string is blank.
///
/// The string to append the backslash to.
/// String with a "/" on the end
public static String PathSlash(string path)
{
string separator = Convert.ToString(Path.DirectorySeparatorChar);
if (path.Length == 0)
return path;
else if (path.EndsWith(separator))
return path;
else
return path + separator;
}
}
}