60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace FileWatcher
|
|
{
|
|
class FilePath
|
|
{
|
|
protected string m_RelativePath;
|
|
protected string m_AbsolutePath;
|
|
|
|
protected bool m_IsRelative;
|
|
|
|
private static Regex regexAbsolutePath = new Regex(@"^[a-zA-Z]\:\\$");
|
|
private static Regex regexNetworkPath = new Regex(@"^\\\\$");
|
|
|
|
FilePath(string path)
|
|
{
|
|
bool match1 = regexAbsolutePath.Matches(path).Count > 0;
|
|
bool match2 = regexNetworkPath.Matches(path).Count > 0;
|
|
|
|
if (match1 == false && match2 == false)
|
|
{
|
|
// Path is not an absolute path
|
|
m_RelativePath = path;
|
|
m_AbsolutePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(new System.IO.FileInfo(Application.ExecutablePath).DirectoryName, path));
|
|
|
|
m_IsRelative = true;
|
|
}
|
|
else
|
|
{
|
|
m_RelativePath = Utils.MakeRelativePath(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), path);
|
|
m_AbsolutePath = path;
|
|
|
|
m_IsRelative = false;
|
|
}
|
|
}
|
|
|
|
|
|
public string AbsolutePath
|
|
{
|
|
get { return m_AbsolutePath; }
|
|
}
|
|
|
|
public string RelativePath
|
|
{
|
|
get { return m_RelativePath; }
|
|
}
|
|
|
|
public bool IsRelative
|
|
{
|
|
get { return m_IsRelative; }
|
|
}
|
|
}
|
|
}
|