public static void CopyResourceToFile()

in AppInstallerFileBuilder/AppInstallerFileBuilderLib/IO/FileSystemUtils.cs [169:202]


        public static void CopyResourceToFile(Assembly executingAssembly, string resourceName, string filePath)
        {
            if (executingAssembly == null)
            {
                throw new ArgumentNullException("executingAssembly");
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException("Resource Name must be provided", "resourceName");
            }

            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new ArgumentException("File path Name must be provided", "filePath");
            }

            string[] embeddedResouceNames = executingAssembly.GetManifestResourceNames();

            foreach (string resource in embeddedResouceNames)
            {
                if (resource.Contains(resourceName))
                {
                    using (var stream = executingAssembly.GetManifestResourceStream(resource))
                    {
                        using (var fileStream = File.Create(filePath))
                        {
                            stream.CopyTo(fileStream);
                            break;
                        }
                    }
                }
            }
        }