public void AddFilesFromEmbeddedNamespace(string path, Assembly resourceAssembly, string embeddedResourcePath) { var matchingResources = resourceAssembly.GetManifestResourceNames() .Where(f => f.StartsWith(embeddedResourcePath)); foreach (var resource in matchingResources) { using (var embeddedResourceStream = resourceAssembly.GetManifestResourceStream(resource)) using (var streamReader = new BinaryReader(embeddedResourceStream ?? throw new InvalidOperationException())) { var fileName = resource.Substring(embeddedResourcePath.Length + 1); var fileData = streamReader.ReadBytes((int)embeddedResourceStream.Length); var filePath = Path.Combine(path, fileName); AddFile(filePath, new VirtualFileData(fileData)); } } }
public static string Combine(this PathBase pathBase, params string[] paths) { return(paths.Aggregate((path, current) => pathBase.Combine(path, current))); }