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


C# FilePath.MakeAbsolute方法代码示例

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


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

示例1: IsNuGetPublished

        public static bool IsNuGetPublished (this ICakeContext context, FilePath file, string nugetSource = DefaultNuGetSource)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var pkg = new ZipPackage (f);

            return IsNuGetPublished (context, pkg.Id, pkg.Version, nugetSource);
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例2: GetNuGetPackageVersion

        public static SemanticVersion GetNuGetPackageVersion (this ICakeContext context, FilePath file)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var p = new ZipPackage (f);

            return p.Version;
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例3: GetNuGetPackageId

        public static string GetNuGetPackageId (this ICakeContext context, FilePath file)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var p = new ZipPackage (f);

            return p.Id;
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例4: SerializeToFile

        public void SerializeToFile ()
        {
            var obj = new TestObject ();

            var file = new FilePath ("./serialized.json");

            context.CakeContext.SerializeJsonToFile (file, obj);

            var json = System.IO.File.ReadAllText (file.MakeAbsolute (context.CakeContext.Environment).FullPath);

            Assert.IsNotEmpty (json);
            Assert.AreEqual (SERIALIZED_JSON, json);
        }
开发者ID:Redth,项目名称:Cake.Json,代码行数:13,代码来源:Test.cs

示例5: SerializeToFile

        public void SerializeToFile ()
        {
            var obj = new TestObject ();

            var file = new FilePath ("./serialized.yaml");

            context.CakeContext.SerializeYamlToFile (file, obj);

            var yaml = System.IO.File.ReadAllText (file.MakeAbsolute (context.CakeContext.Environment).FullPath);

            Assert.IsNotEmpty (yaml);
            Assert.AreEqual (SERIALIZED_YAML, yaml);
        }
开发者ID:Redth,项目名称:Cake.Yaml,代码行数:13,代码来源:Test.cs

示例6: ExecuteProcess

            private void ExecuteProcess(FilePath filePath, ProcessArgumentBuilder arguments, int timeout = 60000)
            {
                try
                {
                    filePath = filePath.MakeAbsolute(_Environment.WorkingDirectory);

                    _Runner.Start(filePath, new ProcessSettings()
                            {
                                Arguments = arguments
                            })
                            .WaitForExit(timeout);
                }
                catch (Exception ex)
                {
                    if (!(ex is TimeoutException)) throw;

                    _Log.Warning("Process timed out!");
                }
            }
开发者ID:SharpeRAD,项目名称:Cake.Topshelf,代码行数:19,代码来源:TopshelfManager.cs

示例7: FileAppendLines

        public static void FileAppendLines (this ICakeContext context, FilePath file, string[] lines)
        {
            var filename = file.MakeAbsolute (context.Environment).FullPath;

            File.AppendAllLines (filename, lines);
        }
开发者ID:Redth,项目名称:Cake.FileHelpers,代码行数:6,代码来源:FileHelpers.cs

示例8: FileAppendText

        public static void FileAppendText (this ICakeContext context, FilePath file, string text)
        {
            var filename = file.MakeAbsolute (context.Environment).FullPath;

            File.AppendAllText (filename, text);
        }
开发者ID:Redth,项目名称:Cake.FileHelpers,代码行数:6,代码来源:FileHelpers.cs

示例9: FileReadLines

        public static string[] FileReadLines (this ICakeContext context, FilePath file)
        {
            var filename = file.MakeAbsolute (context.Environment).FullPath;

            return File.ReadAllLines (filename);
        }
开发者ID:Redth,项目名称:Cake.FileHelpers,代码行数:6,代码来源:FileHelpers.cs

示例10: Download

            /// <summary>
            /// Downloads the content from Amazon S3 and writes it to the specified file.
            /// </summary>
            /// <param name="filePath">The file path of the file to upload.</param>
            /// <param name="key">The key under which the Amazon S3 object is stored.</param>
            /// <param name="version">The identifier for the specific version of the object to be downloaded, if required.</param>
            /// <param name="settings">The <see cref="DownloadSettings"/> required to download from Amazon S3.</param>
            public void Download(FilePath filePath, string key, string version, DownloadSettings settings)
            {
                TransferUtility utility = this.GetUtility(settings);
                TransferUtilityDownloadRequest request = this.CreateDownloadRequest(settings);

                this.SetWorkingDirectory(settings);
                string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath;

                request.FilePath = fullPath;
                request.Key = key;

                if (!String.IsNullOrEmpty(version))
                {
                    request.VersionId = version;
                }

                request.WriteObjectProgressEvent += new EventHandler<WriteObjectProgressArgs>(this.WriteObjectProgressEvent);

                _Log.Verbose("Downloading file {0} from bucket {1}...", key, settings.BucketName);
                utility.Download(request);
            }
开发者ID:SharpeRAD,项目名称:Cake.AWS.S3,代码行数:28,代码来源:S3Manager.cs

示例11: Upload

            /// <summary>
            /// Uploads the specified file. For large uploads, the file will be divided and uploaded in parts 
            /// using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.
            /// </summary>
            /// <param name="filePath">The file path of the file to upload.</param>
            /// <param name="key">The key under which the Amazon S3 object is stored.</param>
            /// <param name="settings">The <see cref="UploadSettings"/> required to upload to Amazon S3.</param>
            public void Upload(FilePath filePath, string key, UploadSettings settings)
            {
                TransferUtility utility = this.GetUtility(settings);
                TransferUtilityUploadRequest request = this.CreateUploadRequest(settings);

                this.SetWorkingDirectory(settings);
                string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath;

                request.FilePath = fullPath;
                request.Key = key;



                //Set ContentType
                if (settings.GenerateContentType && String.IsNullOrEmpty(request.Headers.ContentType))
                {
                    request.Headers.ContentType = new Mime().Lookup(filePath.GetFilename().FullPath);
                }



                //Set Hash Tag
                string hash = "";

                if (!String.IsNullOrEmpty(request.Headers["ETag"]))
                {
                    hash = request.Headers["ETag"];
                }
                else if (settings.GenerateETag || settings.GenerateHashTag)
                {
                    hash = this.GetHash(_FileSystem.GetFile(fullPath));
                    request.Headers["ETag"] = hash;
                }

                if (settings.GenerateHashTag)
                {
                    request.Metadata.Add("HashTag", hash);
                }

                request.UploadProgressEvent += new EventHandler<UploadProgressArgs>(UploadProgressEvent);

                _Log.Verbose("Uploading file {0} to bucket {1}...", key, settings.BucketName);
                utility.Upload(request);
            }
开发者ID:SharpeRAD,项目名称:Cake.AWS.S3,代码行数:51,代码来源:S3Manager.cs

示例12: SyncDownload

            /// <summary>
            /// Syncs the specified file from Amazon S3, checking the modified date of the local files with existing S3Objects and downloading them if its changed.
            /// </summary>
            /// <param name="filePath">The file path to sync to S3</param>
            /// <param name="settings">The <see cref="SyncSettings"/> required to sync to Amazon S3.</param>
            /// <returns>The key that require invalidating.</returns>
            public string SyncDownload(FilePath filePath, SyncSettings settings)
            {
                //Get Directory
                this.SetWorkingDirectory(settings);
                string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath;
                if (!fullPath.EndsWith("/"))
                {
                    fullPath += "/";
                }

                IFile file = _FileSystem.GetFile(filePath.MakeAbsolute(settings.WorkingDirectory));

                if (settings.ModifiedCheck == ModifiedCheck.Hash)
                {
                    settings.GenerateETag = true;
                }
                
                string key = this.GetKey(file, fullPath, settings.LowerPaths, settings.KeyPrefix);
                S3Object obj = this.GetObject(key, "", settings);

                IList<SyncPath> download = new List<SyncPath>();



                if ((file.Exists) && (obj != null))
                {
                    //Get ETag
                    string eTag = "";
                    if (settings.GenerateETag || (settings.ModifiedCheck == ModifiedCheck.Hash))
                    {
                        eTag = this.GetHash(file);
                    }



                    //Check Modified
                    if (((settings.ModifiedCheck == ModifiedCheck.Hash) && (obj.ETag != "\"" + eTag + "\""))
                        || ((settings.ModifiedCheck == ModifiedCheck.Date) && ((DateTimeOffset)new FileInfo(file.Path.FullPath).LastWriteTime) < (DateTimeOffset)obj.LastModified))
                    {
                        download.Add(new SyncPath()
                        {
                            Path = file.Path,
                            Key = key
                        });
                    }
                }
                else if (obj != null)
                {
                    download.Add(new SyncPath()
                    {
                        Path = this.GetPath(fullPath, obj.Key),
                        Key = obj.Key
                    });
                }
                else
                {
                    //Delete
                    file.Delete();
                    
                    _Log.Verbose("Deleting file {0}", file.Path.FullPath);
                    return key;
                }



                //Download
                this.LogProgress = false;
                this.Download(download, settings);

                return (download.Count > 0) ? key : "";
            }
开发者ID:SharpeRAD,项目名称:Cake.AWS.S3,代码行数:77,代码来源:S3Manager.cs

示例13: SyncUpload

            /// <summary>
            /// Syncs the specified file to Amazon S3, checking the modified date of the local files with existing S3Objects and uploading them if its changes.
            /// </summary>
            /// <param name="filePath">The file path to sync to S3</param>
            /// <param name="settings">The <see cref="SyncSettings"/> required to sync to Amazon S3.</param>
            /// <returns>The key that require invalidating.</returns>
            public string SyncUpload(FilePath filePath, SyncSettings settings)
            {
                //Get Directory
                this.SetWorkingDirectory(settings);
                string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath;

                IFile file = _FileSystem.GetFile(filePath.MakeAbsolute(settings.WorkingDirectory));

                if (settings.ModifiedCheck == ModifiedCheck.Hash)
                {
                    settings.GenerateETag = true;
                }

                string key = this.GetKey(file, fullPath, settings.LowerPaths, settings.KeyPrefix);
                S3Object obj = this.GetObject(key, "", settings);



                if (file.Exists)
                {
                    //Get ETag
                    string eTag = "";
                    if (settings.GenerateETag || (settings.ModifiedCheck == ModifiedCheck.Hash))
                    {
                        eTag = this.GetHash(file);
                    }



                    //Check Modified
                    IList<SyncPath> upload = new List<SyncPath>();

                    if ((obj == null)
                        || ((settings.ModifiedCheck == ModifiedCheck.Hash) && (obj.ETag != "\"" + eTag + "\""))
                        || ((settings.ModifiedCheck == ModifiedCheck.Date) && ((DateTimeOffset)new FileInfo(file.Path.FullPath).LastWriteTime) > (DateTimeOffset)obj.LastModified))
                    {
                        upload.Add(new SyncPath()
                        {
                            Path = file.Path,
                            Key = key,
                            ETag = eTag
                        });
                    }



                    //Upload
                    this.LogProgress = false;
                    this.Upload(upload, settings);

                    return key;
                }
                else if (obj != null)
                {
                    this.Delete(key, "", settings);

                    return key;
                }
                else
                {
                    return "";
                }
            }
开发者ID:SharpeRAD,项目名称:Cake.AWS.S3,代码行数:69,代码来源:S3Manager.cs

示例14: GenerateEncryptionKey

            /// <summary>
            /// Generates a base64-encoded encryption key for Amazon S3 to use to encrypt / decrypt objects
            /// </summary>
            /// <param name="filePath">The file path to store the key in.</param>
            /// <param name="size">The size in bits of the secret key used by the symmetric algorithm</param>
            public void GenerateEncryptionKey(FilePath filePath, int size)
            {
                string fullPath = filePath.MakeAbsolute(_Environment.WorkingDirectory).FullPath;

                Aes aesEncryption = Aes.Create();
                aesEncryption.KeySize = size;
                aesEncryption.GenerateKey();

                string base64Key = Convert.ToBase64String(aesEncryption.Key);
                File.WriteAllText(fullPath, base64Key);
            }
开发者ID:SharpeRAD,项目名称:Cake.AWS.S3,代码行数:16,代码来源:S3Manager.cs


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