none
請問一下:如何取得 SQL CE database version RRS feed

解答

  •  

    internal enum SSCEVersion
    {
      Unknown,
      v3_1,
      v3_5
    }
    internal static SSCEVersion GetDatabaseVersion(string path)
    {
      uint signature = 0;
      using (FileStream stream = new FileStream(path, FileMode.Open))
      {
          using (BinaryReader reader = new BinaryReader(stream))
             {
                  stream.Seek(16, SeekOrigin.Begin);
                  signature = reader.ReadUInt32();
             }
       }
      switch (signature)
      {
        case 0x00357b9d: // 3.5
           return SSCEVersion.v3_5;
        case 0x002dd714: // 3.1
          return SSCEVersion.v3_1;
        default:
           return SSCEVersion.Unknown;
       }
    }

    2008年10月7日 下午 02:20