Example #1
0
        public static Stream GetForUpdate_CreateIfNeeded(string fullPath, IData_Base oOut)
        {
            Stream r = null;

            if (!File.Exists(fullPath))
            {
                // not there yet
                oOut.NetIniMembers();
                r = OpenFile.ForWrite(fullPath, s_log);
                using (BinaryWriter bw = new BinaryWriter(r))
                {
                    oOut.NetTo(bw);
                }
            }

            r = OpenFile.ForRead(fullPath, true, true, s_log);
            oOut.NetFrom(new BinaryReader(r));
            return(r);
        }
Example #2
0
        public static void WriteToFile(this MyFolders folder, NiceSystemInfo systemInfo, IData_Base data, IMyLog log)
        {
            string file = FolderNames.GetFolder(systemInfo, folder) + Path.DirectorySeparatorChar + data.GetFileName();

            using (BinaryWriter bw = new BinaryWriter(OpenFile.ForWrite(file, log)))
            {
                data.NetTo(bw);
            }
        }