Exemple #1
0
        /// <summary>
        /// Gets the path from assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="fileSegment">The file segment.</param>
        public static string GetPathFromAssembly(Assembly assembly, string fileSegment)
        {
            if (string.IsNullOrEmpty(fileSegment))
            {
                throw new ArgumentNullException("fileSegment", "The expected file segment is not here.");
            }

            fileSegment = FrameworkFileUtility.TrimLeadingDirectorySeparatorChars(fileSegment);
            if (Path.IsPathRooted(fileSegment))
            {
                throw new FormatException("The expected relative path is not here.");
            }

            var levels = FrameworkFileUtility.CountParentDirectoryChars(fileSegment);

            fileSegment = FrameworkFileUtility.TrimParentDirectoryChars(fileSegment);

            var root = GetPathFromAssembly(assembly);

            if (levels > 0)
            {
                root = FrameworkFileUtility.GetParentDirectory(root, levels);
            }
            root = Path.GetDirectoryName(Path.Combine(root, fileSegment));
            var path = Path.Combine(root, Path.GetFileName(fileSegment));

            return(path);
        }
 /// <summary>
 /// Gets the UTF-8 encoded string.
 /// </summary>
 /// <param name="rawValue">The raw value.</param>
 public static string GetEncodedString(string rawValue)
 {
     return(FrameworkFileUtility.GetEncodedString(rawValue, Encoding.UTF8));
 }