예제 #1
0
        public void AddTableName(String dbPath, String database, String tableName)
        {
            SysTables  st        = new SysTables();
            IFormatter formatter = new BinaryFormatter();
            String     path      = dbPath + database + "/Sysdb/systable.obj";

            Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read);

            try
            {
                if (File.Exists(path))
                {
                    st = (SysTables)(formatter.Deserialize(stream));

                    Console.WriteLine(st);
                    stream.Close();
                }
                st.sys_table.Add(tableName);

                // remove file with new file of the same name if file exists
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                //IFormatter formatter = new BinaryFormatter();
                stream = new FileStream(path, FileMode.Create, FileAccess.Write);
                formatter.Serialize(stream, st);
                stream.Close();
            }
            catch (IOException i)
            {
            }
        }
예제 #2
0
        public void CreateSystable()
        {
            SysTables  st        = new SysTables();
            IFormatter formatter = new BinaryFormatter();
            String     path      = @databaseLocation + "/Sysdb/systable.obj";

            IFormatter ibin = new BinaryFormatter();         // create the binary formatter

            Stream strobj = new FileStream(@path,            //file location

                                           FileMode.Create,  // create folder

                                           FileAccess.Write, // write the file

                                           FileShare.None);

            ibin.Serialize(strobj, st); //written to the file

            strobj.Close();
        }
예제 #3
0
        public bool ValidTableName(String dbPath, String database, String tableName)
        {
            IFormatter formatter  = new BinaryFormatter();
            String     path       = dbPath + database + "/sysdb/systable.obj";
            Stream     stream     = new FileStream(path, FileMode.Open, FileAccess.Read);
            SysTables  st         = null;
            bool       validTable = false;

            try
            {
                st = (SysTables)(formatter.Deserialize(stream));
                Console.WriteLine(st);
                validTable = st.sys_table.Contains(tableName);
                stream.Close();
            }
            catch (IOException)
            {
                return(validTable);
            }
            return(validTable);
        }