Exemplo n.º 1
0
        private AppInfo GenerateIndexFile(string appName, Version ver, string appBasePath)
        {
            var dir   = new DirectoryInfo(appBasePath);
            var files = dir.GetFiles();

            if (files.Length == 0)
            {
                return(null);
            }
            var indexFile = new AppInfo()
            {
                AppBasePath = appBasePath,
                AppName     = appName,
                Version     = ver,
            };

            foreach (var fileInfo in files)
            {
                var fileDetail = new FileDetail(fileInfo);
                indexFile.Files.Add(fileDetail);
            }

            var serializer    = new XmlSerializer(typeof(AppInfo), new Type[] { typeof(FileDetail) });
            var indexFileName = Path.Combine(appBasePath, "index.xml");

            using (var file = File.OpenWrite(indexFileName))
            {
                serializer.Serialize(file, indexFile);
            }

            //indexFile.Files.Insert(0, new FileDetail(new FileInfo(indexFileName)));


            return(indexFile);
        }
Exemplo n.º 2
0
        private AppInfo GenerateIndexFile(string appName, Version ver, string appBasePath)
        {
            var dir = new DirectoryInfo(appBasePath);
            var files = dir.GetFiles();
            if (files.Length == 0) return null;
            var indexFile = new AppInfo()
            {
                AppBasePath = appBasePath,
                AppName = appName,
                Version = ver,
            };
            foreach (var fileInfo in files)
            {
                var fileDetail = new FileDetail(fileInfo);
                indexFile.Files.Add(fileDetail);
            }

            var serializer = new XmlSerializer(typeof(AppInfo), new Type[] { typeof(FileDetail) });
            var indexFileName = Path.Combine(appBasePath, "index.xml");
            using (var file = File.OpenWrite(indexFileName))
            {
                serializer.Serialize(file, indexFile);
            }

            //indexFile.Files.Insert(0, new FileDetail(new FileInfo(indexFileName)));


            return indexFile;
        }