Dev2.DynamicServices.StudioFileSystem.GetRelativePath C# (CSharp) Method

GetRelativePath() public method

public GetRelativePath ( string relativePath ) : string
relativePath string
return string
        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

Same methods

StudioFileSystem::GetRelativePath ( string relativePath, SpecialFolder folder ) : string