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


C# IAbsoluteFilePath.ToString方法代码示例

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


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

示例1: TryCheckUac

        async Task<bool> TryCheckUac(IAbsoluteDirectoryPath mp, IAbsoluteFilePath path) {
            Exception ex;
            try {
                mp.MakeSurePathExists();
                if (path.Exists)
                    File.Delete(path.ToString());
                using (File.CreateText(path.ToString())) {}
                File.Delete(path.ToString());
                return false;
            } catch (UnauthorizedAccessException e) {
                ex = e;
            } catch (Exception e) {
                this.Logger().FormattedWarnException(e);
                return false;
            }

            var report = await UserErrorHandler.HandleUserError(new UserErrorModel("Restart the application elevated?",
                             $"The application failed to write to the path, probably indicating permission issues\nWould you like to restart the application Elevated?\n\n {mp}",
                             RecoveryCommands.YesNoCommands, null, ex)) == RecoveryOptionResultModel.RetryOperation;

            if (!report)
                return false;
            RestartWithUacInclEnvironmentCommandLine();
            return true;
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:25,代码来源:Restarter.cs

示例2: TryDownloadAsync

        async Task TryDownloadAsync(TransferSpec spec, IWebClient webClient, IAbsoluteFilePath tmpFile) {
            try {
                tmpFile.RemoveReadonlyWhenExists();
                if (!string.IsNullOrWhiteSpace(spec.Uri.UserInfo))
                    webClient.SetAuthInfo(spec.Uri);
                using (webClient.HandleCancellationToken(spec))
                    await webClient.DownloadFileTaskAsync(spec.Uri, tmpFile.ToString()).ConfigureAwait(false);
                VerifyIfNeeded(spec, tmpFile);
                _fileOps.Move(tmpFile, spec.LocalFile);
            } catch (OperationCanceledException e) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                throw CreateTimeoutException(spec, e);
            } catch (WebException ex) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                var cancelledEx = ex.InnerException as OperationCanceledException;
                if (cancelledEx != null)
                    throw CreateTimeoutException(spec, cancelledEx);
                if (ex.Status == WebExceptionStatus.RequestCanceled)
                    throw CreateTimeoutException(spec, ex);

                var response = ex.Response as HttpWebResponse;
                if (response == null)
                    throw GenerateDownloadException(spec, ex);

                switch (response.StatusCode) {
                case HttpStatusCode.NotFound:
                    throw new RequestFailedException("Received a 404: NotFound response", ex);
                case HttpStatusCode.Forbidden:
                    throw new RequestFailedException("Received a 403: Forbidden response", ex);
                case HttpStatusCode.Unauthorized:
                    throw new RequestFailedException("Received a 401: Unauthorized response", ex);
                }
                throw GenerateDownloadException(spec, ex);
            }
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:35,代码来源:HttpDownloadProtocol.cs

示例3: SHA1FileHash

            public string SHA1FileHash(IAbsoluteFilePath fileName) {
                Contract.Requires<ArgumentNullException>(fileName != null);

                return FileUtil.Ops.AddIORetryDialog(() => {
                    using (var fs = new FileStream(fileName.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var stream = new BufferedStream(fs, GetBufferSize(fs)))
                    using (var md5 = new SHA1CryptoServiceProvider())
                        return GetHash(md5.ComputeHash(stream));
                }, fileName.ToString());
            }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:10,代码来源:HashEncryption.cs

示例4: GenerateCommandLineExecution

 public static IEnumerable<string> GenerateCommandLineExecution(IAbsoluteFilePath location, string executable,
     params string[] desiredParams) {
     var updateExe = GetUpdateExe(location);
     return (updateExe != null) && updateExe.Exists
         ? new[] {updateExe.ToString()}.Concat(Restarter.BuildUpdateExeArguments(executable, desiredParams))
         : new[] {location.ToString()}.Concat(desiredParams);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:7,代码来源:StartWithWindowsHandler.cs

示例5: Gzip

            public virtual string Gzip(IAbsoluteFilePath file, IAbsoluteFilePath dest = null,
                bool preserveFileNameAndModificationTime = true, ITProgress status = null) {
                Contract.Requires<ArgumentNullException>(file != null);
                Contract.Requires<ArgumentException>(file.Exists);

                var defDest = (file + ".gz").ToAbsoluteFilePath();
                if (dest == null)
                    dest = defDest;

                var cmd = $"-f --best --rsyncable --keep \"{file}\"";
                if (!preserveFileNameAndModificationTime)
                    cmd = "-n " + cmd;

                dest.RemoveReadonlyWhenExists();

                var startInfo =
                    new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
                        WorkingDirectory = file.ParentDirectoryPath
                    }.Build();

                var srcSize = file.FileInfo.Length;
                ProcessExitResultWithOutput ret;
                var predictedSize = srcSize*DefaultPredictedCompressionRatio;
                using (StatusProcessor.Conditional(defDest, status, (long) predictedSize))
                    ret = ProcessManager.LaunchAndGrabTool(startInfo, "Gzip pack");
                if (Path.GetFullPath(dest.ToString()) != Path.GetFullPath(defDest.ToString()))
                    FileUtil.Ops.MoveWithRetry(defDest, dest);

                return ret.StandardOutput + ret.StandardError;
            }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:30,代码来源:ToolsGzipTools.cs

示例6: Gzip

            public virtual string Gzip(IAbsoluteFilePath file, IAbsoluteFilePath dest = null,
                bool preserveFileNameAndModificationTime = false) {
                Contract.Requires<ArgumentNullException>(file != null);
                Contract.Requires<ArgumentException>(file.Exists);

                var defDest = (file + ".gz").ToAbsoluteFilePath();
                if (dest == null)
                    dest = defDest;

                var cmd = String.Format("-f --best --rsyncable --keep \"{0}\"", file);
                if (!preserveFileNameAndModificationTime)
                    cmd = "-n " + cmd;

                dest.RemoveReadonlyWhenExists();

                var startInfo =
                    new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
                        WorkingDirectory = file.ParentDirectoryPath.ToString()
                    }.Build();
                var ret = ProcessManager.LaunchAndGrabTool(startInfo, "Gzip pack");

                if (Path.GetFullPath(dest.ToString()) != Path.GetFullPath(defDest.ToString()))
                    FileUtil.Ops.MoveWithRetry(defDest, dest);

                return ret.StandardOutput + ret.StandardError;
            }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:26,代码来源:GzipTools.cs

示例7: YomaConfig

 public YomaConfig(IAbsoluteFilePath inputAddonsFile, IAbsoluteFilePath inputModsFile,
     IAbsoluteFilePath inputServerFile = null)
     : this(
         XDocument.Load(inputAddonsFile.ToString()), XDocument.Load(inputModsFile.ToString()),
         inputServerFile == null ? null : XDocument.Load(inputServerFile.ToString())) {
     Contract.Requires<ArgumentOutOfRangeException>(inputAddonsFile != null);
     Contract.Requires<ArgumentOutOfRangeException>(inputModsFile != null);
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:8,代码来源:YomaConfig.cs

示例8: UnpackUpdater

            public virtual void UnpackUpdater(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder,
                bool overwrite = false, bool fullPath = true) {
                Contract.Requires<ArgumentNullException>(sourceFile != null);
                Contract.Requires<ArgumentNullException>(outputFolder != null);

                Generic.RunUpdater(UpdaterCommands.Unpack, sourceFile.ToString(), outputFolder.ToString(),
                    overwrite ? "--overwrite" : null,
                    fullPath.ToString());
            }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:9,代码来源:ToolsCompression.cs

示例9: PackTar

 public void PackTar(IAbsoluteDirectoryPath directory, IAbsoluteFilePath outputFile) {
     using (var tarStream = File.OpenWrite(outputFile.ToString()))
     using (var af = WriterFactory.Open(tarStream, ArchiveType.Tar, CompressionType.None)) {
         foreach (var f in directory.DirectoryInfo.EnumerateFiles("*", SearchOption.AllDirectories))
             af.Write(f.FullName.Replace(directory.ParentDirectoryPath + @"\", ""), f.FullName);
         // This ommits the root folder ('userconfig')
         //af.WriteAll(directory.ToString(), "*", SearchOption.AllDirectories);
     }
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:9,代码来源:Compression.cs

示例10: RunExtractPboWithParameters

        public void RunExtractPboWithParameters(IAbsoluteFilePath input, IAbsoluteDirectoryPath output,
            params string[] parameters) {
            if (!input.Exists)
                throw new IOException("File doesn't exist: " + input);
            var startInfo =
                new ProcessStartInfoBuilder(_extractPboBin,
                    BuildParameters(input.ToString(), output.ToString(), parameters)).Build();

            ProcessExitResult(_processManager.LaunchAndGrabTool(startInfo));
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:10,代码来源:PboTools.cs

示例11: CreateZip

 public void CreateZip(IAbsoluteDirectoryPath directory, IAbsoluteFilePath outputFile) {
     using (var arc = ZipArchive.Create()) {
         foreach (var f in directory.DirectoryInfo.EnumerateFiles("*", SearchOption.AllDirectories))
             arc.AddEntry(f.FullName.Replace(directory.ParentDirectoryPath + @"\", ""), f.FullName);
         arc.SaveTo(outputFile.ToString(),
             new ZipWriterOptions(CompressionType.Deflate) {
                 DeflateCompressionLevel = CompressionLevel.BestCompression
             });
     }
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:10,代码来源:CompressionUtil.cs

示例12: BiKeyPair

        public BiKeyPair(IAbsoluteFilePath path) {
            Contract.Requires<ArgumentNullException>(path != null);
            Contract.Requires<ArgumentOutOfRangeException>(!path.FileName.Contains("@"));

            var p = path.ToString().Replace(".biprivatekey", String.Empty).Replace(".bikey", String.Empty);
            Location = Path.GetDirectoryName(p);
            Name = Path.GetFileName(p);
            CreatedAt = File.GetCreationTime(p);
            PrivateFile = (p + ".biprivatekey").ToAbsoluteFilePath();
            PublicFile = (p + ".bikey").ToAbsoluteFilePath();
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:11,代码来源:BiKeyPair.cs

示例13: TryDownloadAsync

        async Task TryDownloadAsync(TransferSpec spec, IWebClient webClient, IAbsoluteFilePath tmpFile) {
            try {
                tmpFile.RemoveReadonlyWhenExists();
                if (!string.IsNullOrWhiteSpace(spec.Uri.UserInfo))
                    webClient.SetAuthInfo(spec.Uri);
                using (webClient.HandleCancellationToken(spec))
                    await webClient.DownloadFileTaskAsync(spec.Uri, tmpFile.ToString()).ConfigureAwait(false);
                VerifyIfNeeded(spec, tmpFile);
                _fileOps.Move(tmpFile, spec.LocalFile);
            } catch (OperationCanceledException e) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                throw CreateTimeoutException(spec, e);
            } catch (WebException e) {
                _fileOps.DeleteIfExists(tmpFile.ToString());
                var cancelledEx = e.InnerException as OperationCanceledException;
                if (cancelledEx != null)
                    throw CreateTimeoutException(spec, cancelledEx);
                if (e.Status == WebExceptionStatus.RequestCanceled)
                    throw CreateTimeoutException(spec, e);

                GenerateDownloadException(spec, e);
            }
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:23,代码来源:HttpDownloadProtocol.cs

示例14: UnpackGzip

 public void UnpackGzip(IAbsoluteFilePath sourceFile, IAbsoluteFilePath destFile, ITProgress progress = null) {
     using (var archive = GZipArchive.Open(sourceFile.ToString())) {
         try {
             TryUnpackArchive(destFile, progress, archive);
         } catch (ZlibException ex) {
             if ((ex.Message == "Not a valid GZIP stream.") || (ex.Message == "Bad GZIP header.")
                 || (ex.Message == "Unexpected end-of-file reading GZIP header.")
                 || (ex.Message == "Unexpected EOF reading GZIP header.")) {
                 var header = TryReadHeader(sourceFile);
                 throw new CompressedFileException(
                     $"The archive appears corrupt: {sourceFile}. Header:\n{header}", ex);
             }
             throw;
         }
     }
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:16,代码来源:CompressionUtil.cs

示例15: Unpack

            public virtual void Unpack(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder,
                bool overwrite = false, bool fullPath = true, bool force7z = false, bool checkFileIntegrity = true,
                ITProgress progress = null) {
                Contract.Requires<ArgumentNullException>(sourceFile != null);
                Contract.Requires<ArgumentNullException>(outputFolder != null);

                var ext = sourceFile.FileExtension;
                if (force7z ||
                    SevenzipArchiveFormats.Any(x => ext.Equals(x, StringComparison.OrdinalIgnoreCase))) {
                    using (var extracter = new SevenZipExtractor(sourceFile.ToString()))
                        UnpackArchive(sourceFile, outputFolder, overwrite, checkFileIntegrity, extracter);
                } else {
                    var options = fullPath ? ExtractOptions.ExtractFullPath : ExtractOptions.None;
                    using (var archive = GetArchiveWithGzWorkaround(sourceFile, ext))
                        UnpackArchive(outputFolder, overwrite, archive, options);
                }
            }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:17,代码来源:Compression.cs


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