本文整理汇总了C#中FilePath.GetFilename方法的典型用法代码示例。如果您正苦于以下问题:C# FilePath.GetFilename方法的具体用法?C# FilePath.GetFilename怎么用?C# FilePath.GetFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath.GetFilename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static BlogFilename Parse(FilePath path)
{
var match = FilenameRegex.Match(path.GetFilename().FullPath);
if (!match.Success)
{
return null;
}
var year = match.Groups["year"].Value;
var month = match.Groups["month"].Value;
var day = match.Groups["day"].Value;
return new BlogFilename
{
Slug = match.Groups["slug"].Value.ToSlug(),
PostedAt = DateTime.ParseExact(year + month + day, "yyyyMMdd", CultureInfo.InvariantCulture)
};
}
示例2: File
public ReleaseBuilder File(FilePath file)
{
FileSettings.FilePath = file;
if (string.IsNullOrWhiteSpace(FileSettings.FileName))
FileSettings.FileName = file.GetFilename().FullPath;
return this;
}
示例3: 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);
}