Beispiel #1
0
        public static void Serialize(FileInfo file, Action <GenericWriter> serializer)
        {
            file.Refresh();

            if (file.Directory != null && !file.Directory.Exists)
            {
                file.Directory.Create();
            }

            if (!file.Exists)
            {
                file.Create().Close();
            }

            file.Refresh();

            using (var fs = file.OpenWrite())
            {
                var writer = new BinaryFileWriter(fs, true);

                try
                {
                    serializer(writer);
                }
                finally
                {
                    writer.Flush();
                    writer.Close();
                }
            }
        }
        private void SaveTypeDatabase(string path, List <Type> types)
        {
            BinaryFileWriter bfw = new BinaryFileWriter(path, false);

            bfw.Write(types.Count);

            foreach (Type type in types)
            {
                bfw.Write(type.FullName);
            }

            bfw.Flush();

            bfw.Close();
        }