Plugin.EmbeddedResource/ResourceWriter.cs
/// <summary>
/// Writes all of the embedded resources in a project folder to the target directory
/// </summary>
/// <param name="assembly"><see cref="Assembly"/> containing embedded resources.</param>
/// <param name="sourceDirectory">Path to embedded resources in assembly.</param>
/// <param name="targetDirectory">Path to folder where resources will be written.</param>
/// <param name="recursive">Descend into subdirectories to retrieve resources.  
/// Recursive writes will treat "." as path delimiters (excluding a final "." for the file extension). 
/// Non-recursive treats all "." as part of the file name.</param>
/// <returns>
/// A <see cref="Task"/> which will complete after the folder is written
/// </returns>
Writes all of the embedded resources in a project folder to the target directory
Writes all of the embedded resources in a project folder to the target directory
public static async Task WriteFolder (Assembly assembly, string sourceDirectory, string targetDirectory = "", bool recursive = true, CreationCollisionOption option =  CreationCollisionOption.ReplaceExisting) {
			var sourcePrefix = String.Format ("{0}.{1}.",
				assembly.GetName ().Name,
				ConvertPathToResourceName (sourceDirectory));
			foreach (var resource in assembly.GetManifestResourceNames()
				.Where(a => a.StartsWith(sourcePrefix))
				.Select(b => b)) {
				var relativePathAndFilename = resource.Substring (sourcePrefix.Length);
				if (recursive) {
					var lastDot = relativePathAndFilename.LastIndexOf (".");
					if (lastDot > -1)
						relativePathAndFilename = 
							relativePathAndFilename.Substring (0, lastDot).Replace ('.', PortablePath.DirectorySeparatorChar) +
							"." +
							relativePathAndFilename.Substring (lastDot + 1);
				}
				await WriteResource (
					assembly,
					PortablePath.Combine (targetDirectory, relativePathAndFilename), 
					resource,
					option);
			}
		}
public static async Task WriteFolder ( Assembly assembly , string sourceDirectory , string targetDirectory = " " , bool recursive = true , CreationCollisionOption option = CreationCollisionOption . ReplaceExisting ) { var sourcePrefix = String . Format ( " " , assembly . GetName ( ) . Name , ConvertPathToResourceName ( sourceDirectory ) ) ; foreach ( var resource in assembly . GetManifestResourceNames ( ) . Where ( a => a . StartsWith ( sourcePrefix ) ) . Select ( b => b ) ) { var relativePathAndFilename = resource . Substring ( sourcePrefix . Length ) ; if ( recursive ) { var lastDot = relativePathAndFilename . LastIndexOf ( " " ) ; if ( lastDot > - 1 ) relativePathAndFilename = relativePathAndFilename . Substring ( 0 , lastDot ) . Replace ( ' ' , PortablePath . DirectorySeparatorChar ) + " " + relativePathAndFilename . Substring ( lastDot + 1 ) ; } await WriteResource ( assembly , PortablePath . Combine ( targetDirectory , relativePathAndFilename ) , resource , option ) ; } }
Writes all of the embedded resources in a project folder to the target directory
Writes all of the embedded resources in a project folder to the target directory
// strip assembly name from resource // .NET embedded resources replace path delimiters with "." // on recursive write, turn "." into directory separators // assume that the last "." is the file extension delimiter // treat any other "." as a path delimiter
A  which will complete after the folder is written
A which will complete after the folder is written
assembly
Assembly
containing embedded resources.
containing embedded resources .
sourceDirectory
string
Path to embedded resources in assembly.
Path to embedded resources in assembly .
targetDirectory
string
Path to folder where resources will be written.
Path to folder where resources will be written .
recursive
bool
Descend into subdirectories to retrieve resources.
Recursive writes will treat "." as path delimiters (excluding a final "." for the file extension).
Non-recursive treats all "." as part of the file name.
Descend into subdirectories to retrieve resources . Recursive writes will treat " . " as path delimiters ( excluding a final " . " for the file extension ) . Non - recursive treats all " . " as part of the file name .
option
CreationCollisionOption