本文整理汇总了C#中ContentManager.ResolveAssetFilePath方法的典型用法代码示例。如果您正苦于以下问题:C# ContentManager.ResolveAssetFilePath方法的具体用法?C# ContentManager.ResolveAssetFilePath怎么用?C# ContentManager.ResolveAssetFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentManager
的用法示例。
在下文中一共展示了ContentManager.ResolveAssetFilePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMachineSpecificAssetCopy
/// <summary>
/// Creates a copy of the specified asset which is specific to the machine that is currently
/// executing the test.
/// </summary>
/// <param name="content">The content manager.</param>
/// <param name="asset">The asset to copy.</param>
/// <returns>The asset path of the new asset file which was created.</returns>
protected String CreateMachineSpecificAssetCopy(ContentManager content, String asset)
{
Contract.Require(content, nameof(content));
Contract.Require(asset, nameof(asset));
var resolvedSourceFile = content.ResolveAssetFilePath(asset);
var resolvedSourceExtension = Path.GetExtension(resolvedSourceFile);
var copiedFileName = $"{Path.GetFileNameWithoutExtension(resolvedSourceFile)}-{Environment.MachineName}{resolvedSourceExtension}";
var copiedFilePath = Path.Combine(Path.GetDirectoryName(resolvedSourceFile), copiedFileName);
var copiedAssetName = Path.GetFileNameWithoutExtension(copiedFileName);
var copiedAssetPath = Path.Combine(Path.GetDirectoryName(asset), copiedAssetName);
File.Copy(resolvedSourceFile, copiedFilePath, true);
return copiedAssetPath;
}