AddFile() public méthode

public AddFile ( string rootPath, string filePath ) : void
rootPath string
filePath string
Résultat void
Exemple #1
0
        private void EmbedSourceFiles(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            var embedFileList = new List <string>();
            var xmlFilePath   = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml");

            var dirInfo     = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                          sourceFile.Name.ToLower() == "v32.cab" ||
                          sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }
                if (embedFileList.Contains(sourceFile.Name, StringComparer.CurrentCultureIgnoreCase))
                {
                    sourceFile.CopyTo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name, true);
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    parameters.EmbeddedResources.Add(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    filesMarkedForDelete.Add(new FileInfo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name));
                }
                else
                {
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);
                    parameters.EmbeddedResources.Add(sourceFile.FullName);
                }
                embedFileList.Add(sourceFile.Name);
            }

            parameters.EmbeddedResources.Add(xmlFilePath);
        }
        private void EmbedSourceFiles(CompilerParameters parameters, string sourcePath, string version = null, OfficeClientEdition officeClientEdition = OfficeClientEdition.Office32Bit)
        {
            var embedFileList = new List<string>();
            var xmlFilePath = DirectoryHelper.GetCurrentDirectoryFilePath("Files.xml"); 

            var dirInfo = new DirectoryInfo(sourcePath);
            var sourceFiles = dirInfo.GetFiles("*.*", SearchOption.AllDirectories);

            var fileCacher = new FilePathCacher(xmlFilePath);

            foreach (var sourceFile in sourceFiles)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    if (!(sourceFile.FullName.ToLower().Contains(version.ToLower()) ||
                        sourceFile.Name.ToLower() == "v32.cab" ||
                        sourceFile.Name.ToLower() == "v64.cab"))
                    {
                        continue;
                    }
                }

                if (officeClientEdition == OfficeClientEdition.Office32Bit)
                {
                    if (sourceFile.Name.ToLower().Contains(".x64."))
                    {
                        continue;
                    }
                }
                else
                {
                    if (sourceFile.Name.ToLower().Contains(".x86."))
                    {
                        continue;
                    }
                }
                if (embedFileList.Contains(sourceFile.Name, StringComparer.CurrentCultureIgnoreCase))
                 {
                    sourceFile.CopyTo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name, true);
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    parameters.EmbeddedResources.Add(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name);
                    filesMarkedForDelete.Add(new FileInfo(sourceFile.DirectoryName + "\\copyof" + sourceFile.Name));
                 }
                 else
                 {
                    fileCacher.AddFile(dirInfo.Parent.FullName, sourceFile.FullName);
                    parameters.EmbeddedResources.Add(sourceFile.FullName);
                 }
                embedFileList.Add(sourceFile.Name);
            }

            parameters.EmbeddedResources.Add(xmlFilePath);
        }