public string GetRelativePath(string relativePath)
{
if(_rootDirectory == null) return relativePath;
string tempPath;
try
{
tempPath = Path.IsPathRooted(relativePath) ? (relativePath.Contains(_rootDirectory) ? relativePath : null) : Path.Combine(_rootDirectory, relativePath);
if(String.IsNullOrEmpty(tempPath))
{
string fileName;
try
{
fileName = Path.GetFileName(relativePath);
}
catch(Exception ex)
{
Dev2Logger.Log.Error(ex);
fileName = null;
}
if(String.IsNullOrEmpty(fileName)) fileName = Path.GetDirectoryName(relativePath);
if(fileName != null)
{
tempPath = Path.Combine(_ensuredDirectories[1], fileName);
}
}
}
catch(Exception ex)
{
Dev2Logger.Log.Error(ex);
tempPath = relativePath;
}
return tempPath;
}
#endregion