예제 #1
0
        private void WriteFiles()
        {
            var binaries = _package.Files.Select(x => x.ShortcutIcon)
                           .Where(x => !string.IsNullOrEmpty(x))
                           .Select(x => x.Trim().ToLowerInvariant())
                           .Distinct()
                           .Concat(_package.Files.Select(x => x.Filename.Trim()))
                           .ToArray();

            Write("Media", 1, binaries.Length + 1, null, CabinetName, null, null);

            foreach (PackageFile file in _package.Files)
            {
                var info = new FileInfo(file.Filename);
                int id   = _ids[file.Filename];

                Write("File", id.ToString(), id.ToString(), $"{id}|{info.Name}", (int)info.Length, null, null, 512, id);
            }

            string cabinet = Path.GetTempFileName();

            using (var stream = File.OpenWrite(cabinet))
            {
                var writer = new CabinetWriter(binaries, x => _ids[x].ToString());
                writer.Write(stream);
            }

            _connection.ExecuteStream("_Streams", cabinet, CabinetName.Substring(1));

            File.Delete(cabinet);
        }
예제 #2
0
        private void WriteFiles()
        {
            var binaries = _package.Files.Select(x => x.ShortcutIcon)
                .Where(x => !string.IsNullOrEmpty(x))
                .Select(x => x.Trim().ToLowerInvariant())
                .Distinct()
                .Concat(_package.Files.Select(x => x.Filename.Trim()))
                .ToArray();

            Write("Media", 1, binaries.Length + 1, null, CabinetName, null, null);

            foreach (PackageFile file in _package.Files)
            {
                var info = new FileInfo(file.Filename);
                int id = _ids[file.Filename];

                Write("File", id.ToString(), id.ToString(), $"{id}|{info.Name}", (int)info.Length, null, null, 512, id);
            }

            string cabinet = Path.GetTempFileName();

            using (var stream = File.OpenWrite(cabinet))
            {
                var writer = new CabinetWriter(binaries, x => _ids[x].ToString());
                writer.Write(stream);
            }

            _connection.ExecuteStream("_Streams", cabinet, CabinetName.Substring(1));

            File.Delete(cabinet);
        }