_04_GuessTheNumberTurnTheTables.FileSystemDatabase.Write C# (CSharp) Method

Write() public method

public Write ( int key, byte[]>.Dictionary obj ) : void
key int
obj byte[]>.Dictionary
return void
        public void Write(int key, Dictionary<string, byte[]> obj)
        {
            lock (this.GetType()) {
                var objDir = Path.Combine (this.directory, key.ToString ());
                if (Directory.Exists (objDir)) {
                    Directory.Delete (objDir, true);
                }
                Directory.CreateDirectory (objDir);
                foreach (var field in obj.Keys) {
                    var fileName = Path.Combine (objDir, field);
                    File.WriteAllBytes (fileName, obj [field]);
                }
            }
        }

Usage Example

示例#1
0
        public void Save(FileSystemDatabase fsd)
        {
            var toSave = new Dictionary <string, byte[]> ();

            toSave [ShovelVmStateName]    = this.ShovelVmState;
            toSave [ShovelVmBytecodeName] = this.ShovelVmBytecode;
            toSave [PageContentName]      = Encoding.UTF8.GetBytes(this.PageContent.ToString());
            toSave [ReadStateName]        = BitConverter.GetBytes((int)this.ReadState);
            toSave [ShovelVmSourcesName]  = Encoding.UTF8.GetBytes(this.ShovelVmSources);
            fsd.Write(this.Id, toSave);
        }
All Usage Examples Of _04_GuessTheNumberTurnTheTables.FileSystemDatabase::Write