C#中检测access mdb 版本
const int JET_2_VERSION_NUMBER_START = 1;
const int JET_VERSION_NUMBER_START = 21;
const int LENGTH = 1;
FileStream fs = new FileStream(textBox1.Text, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryReader br = new BinaryReader(fs);
            string str = new string(br.ReadChars(VERSION_STRING_SIZE));
            MessageBox.Show(str);
            if (str.Substring(JET_2_VERSION_NUMBER_START-1, LENGTH) == string.Format("{0}", (char)1))
                MessageBox.Show("Microsoft Access 2");
            else if (str.Substring(JET_VERSION_NUMBER_START-1, LENGTH) == string.Format("{0}", (char)0))
                MessageBox.Show("Microsoft Access 97");
            else if (str.Substring(JET_VERSION_NUMBER_START-1, LENGTH) == string.Format("{0}", (char)1))
                MessageBox.Show("Microsoft Access 2000/2002");
            else
                MessageBox.Show("no");        // maybe it's 2007
            br.Close();
            fs.Close();
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号