当前位置: 首页>>代码示例>>C#>>正文


C# IFileService.GetFullPath方法代码示例

本文整理汇总了C#中IFileService.GetFullPath方法的典型用法代码示例。如果您正苦于以下问题:C# IFileService.GetFullPath方法的具体用法?C# IFileService.GetFullPath怎么用?C# IFileService.GetFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFileService的用法示例。


在下文中一共展示了IFileService.GetFullPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCanonicalRoot

        /// <summary>
        /// Get the canonical volume root (e.g. the \\?\VolumeGuid format) for the given path. The path must not be relative.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown if the path is relative or indeterminate.</exception>
        /// <exception cref="System.IO.IOException">Thrown if unable to get the root from the OS.</exception>
        public static string GetCanonicalRoot(this IExtendedFileService extendedFileService, IFileService fileService, string path)
        {
            if (Paths.IsRelative(path)) throw new ArgumentException();

            path = fileService.GetFullPath(path);
            int rootLength;
            var format = Paths.GetPathFormat(path, out rootLength);
            if (format == PathFormat.UnknownFormat) throw new ArgumentException();

            string root = path.Substring(0, rootLength);
            string simpleRoot = root;
            string canonicalRoot = root;

            switch (format)
            {
                case PathFormat.UniformNamingConventionExtended:
                    simpleRoot = @"\\" + root.Substring(Paths.ExtendedUncPrefix.Length);
                    goto case PathFormat.UniformNamingConvention;
                case PathFormat.UniformNamingConvention:
                    canonicalRoot = simpleRoot;
                    break;
                case PathFormat.VolumeAbsoluteExtended:
                case PathFormat.DriveAbsolute:
                    canonicalRoot = extendedFileService.GetVolumeName(root);
                    simpleRoot = extendedFileService.GetMountPoint(root);
                    break;
            }

            return canonicalRoot;
        }
开发者ID:ramarag,项目名称:XTask,代码行数:35,代码来源:ExtendedFileServiceExtensions.cs

示例2: SplitFiles

        private static string[] SplitFiles(IFileService fileService, params string[] fileLists)
        {
            if (fileLists == null || fileLists.Length == 0 || fileLists[0] == null) return new string[0];

            List<string> files = new List<string>();
            foreach (string fileList in fileLists)
                foreach (string file in fileList.Split(';'))
                    files.Add(fileService.GetFullPath(file));
            return files.ToArray();
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:10,代码来源:ArgumentProviderExtensions.cs

示例3: SplitAndValidateDirectories

        private static string[] SplitAndValidateDirectories(IFileService fileService, params string[] directoryLists)
        {
            if (directoryLists == null || directoryLists.Length == 0 || directoryLists[0] == null) return new string[0];

            List<string> directories = new List<string>();
            foreach (string directoryList in directoryLists)
                foreach (string directory in directoryList.Split(';'))
                {
                    string normalizedPath = fileService.GetFullPath(directory);
                    if (!fileService.DirectoryExists(normalizedPath))
                        throw new TaskArgumentException(XTaskStrings.ErrorDirectoryNotFound, directory);
                    directories.Add(normalizedPath);
                }
            return directories.ToArray();
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:15,代码来源:ArgumentProviderExtensions.cs

示例4: GetCanonicalRoot

        /// <summary>
        /// Get the canonical volume root (e.g. the \\?\VolumeGuid format) for the given path. The path must not be relative.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown if the path is relative or indeterminate.</exception>
        /// <exception cref="System.IO.IOException">Thrown if unable to get the root from the OS.</exception>
        public static string GetCanonicalRoot(this IExtendedFileService extendedFileService, IFileService fileService, string path)
        {
            if (Paths.IsPartiallyQualified(path)) throw new ArgumentException(nameof(path));

            path = fileService.GetFullPath(path);
            int rootLength;
            var format = Paths.GetPathFormat(path, out rootLength);
            if (format == PathFormat.UnknownFormat) throw new ArgumentException(nameof(format));

            string root = path.Substring(0, rootLength);
            string canonicalRoot = root;

            switch (format)
            {
                case PathFormat.UniformNamingConvention:
                    if (Paths.IsDevice(path)) canonicalRoot = @"\\" + root.Substring(Paths.ExtendedUncPrefix.Length);
                    break;
                case PathFormat.LocalFullyQualified:
                    canonicalRoot = extendedFileService.GetVolumeName(root);
                    break;
            }

            return canonicalRoot;
        }
开发者ID:JeremyKuhne,项目名称:XTask,代码行数:29,代码来源:ExtendedFileServiceExtensions.cs

示例5: Create

        internal static IFileSystemInformation Create(string path, IFileService fileService)
        {
            path = fileService.GetFullPath(path);

            try
            {
                var findResult = NativeMethods.FileManagement.FindFirstFile(path, directoriesOnly: false, getAlternateName: false, returnNullIfNotFound: false);
                var info = Create(findResult, fileService);
                findResult.FindHandle.Close();
                return info;
            }
            catch (System.IO.IOException)
            {
                // Could be a root directory (e.g. C:), can't do FindFile
                if (Paths.IsPathRelative(path))
                {
                    throw;
                }

                System.IO.FileAttributes attributes = NativeMethods.FileManagement.GetFileAttributes(path);
                return Create(path, attributes, fileService);
            }
        }
开发者ID:Priya91,项目名称:XTask,代码行数:23,代码来源:FileSystemInformation.cs


注:本文中的IFileService.GetFullPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。