ImageMagick.FileHelper.CheckForBaseDirectory C# (CSharp) Метод

CheckForBaseDirectory() публичный статический Метод

public static CheckForBaseDirectory ( string fileName ) : string
fileName string
Результат string
    public static string CheckForBaseDirectory(string fileName)
    {
      if (string.IsNullOrEmpty(fileName))
        return fileName;

      if (fileName.Length < 2 || fileName[0] != '~')
        return fileName;

      return AppDomain.CurrentDomain.BaseDirectory + fileName.Substring(1);
    }
  }

Usage Example

        /// <summary>
        /// Performs compression on the specified file. With some formats the image will be decoded
        /// and encoded and this will result in a small quality reduction. If the new file size is not
        /// smaller the file won't be overwritten.
        /// </summary>
        /// <param name="fileName">The file name of the image to compress.</param>
        /// <returns>True when the image could be compressed otherwise false.</returns>
        public bool Compress(string fileName)
        {
            var filePath = FileHelper.CheckForBaseDirectory(fileName);

            Throw.IfNullOrEmpty(nameof(fileName), filePath);

            return(DoCompress(new FileInfo(filePath)));
        }
All Usage Examples Of ImageMagick.FileHelper::CheckForBaseDirectory