Exemplo n.º 1
0
        public bool CreateIDX(char Type, char Group, char Market, string DateTime, string Title, string Content, string[] Code, string UpdateTime)
        {
            this.myIDXformat            = new IDXformat();
            this.myIDXformat.Type       = Type;
            this.myIDXformat.Group      = Group;
            this.myIDXformat.Market     = Market;
            this.myIDXformat.DateTime   = DateTime;
            this.myIDXformat.UpdateTime = UpdateTime;
            this.myIDXformat.Title      = Title;
            int startIndex = this.TXTpath.LastIndexOf('\\') + 1;

            this.myIDXformat.FilePath = this.TXTpath.Substring(startIndex, this.TXTpath.Length - startIndex);
            byte[] bytes = Encoding.GetEncoding("gb2312").GetBytes(Content);
            this.myIDXformat.Length = bytes.Length;
            if (File.Exists(this.TXTpath))
            {
                FileInfo info = new FileInfo(this.TXTpath);
                this.myIDXformat.Offset = (int)info.Length;
                this.txt  = new FileStream(this.TXTpath, FileMode.Append);
                this.txtw = new BinaryWriter(this.txt, Encoding.Default);
            }
            else
            {
                this.txt  = new FileStream(this.TXTpath, FileMode.CreateNew);
                this.txtw = new BinaryWriter(this.txt, Encoding.Default);
                this.myIDXformat.Offset = 0;
            }
            this.txtw.Write(bytes);
            this.myIDXformat.Code1    = Code[0];
            this.myIDXformat.Code2    = Code[1];
            this.myIDXformat.Code3    = Code[2];
            this.myIDXformat.Code4    = Code[3];
            this.myIDXformat.Reserved = new byte[0x38];
            this.myIDXformat.Chksum   = '\0';
            try
            {
                if (this.Buffer != null)
                {
                    this.idxw.Write(this.Buffer);
                }
                this.idxw.Write(this.myIDXformat.ToByteArray());
            }
            catch (Exception exception)
            {
                this.ErrorMsg = exception.Message;
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool Disable(string UpdateTime, string Title)
        {
            bool flag = false;

            if (File.Exists(this.IDXpath))
            {
                this.idx = new FileStream(this.IDXpath, FileMode.Open);
            }
            else
            {
                return(false);
            }
            this.idxr = new BinaryReader(this.idx, Encoding.Default);
            int length = (int)this.idxr.BaseStream.Length;
            int num2   = (length - 0x10) / 0x100;

            this.Buffer = new byte[length];
            this.idxr.Read(this.Buffer, 0, length);
            int num3 = 0;

            byte[] destinationArray = new byte[0x100];
            while ((num3 < num2) && !flag)
            {
                if (this.Buffer[0x10 + (num3 * 0x100)] != 0x80)
                {
                    Array.Copy(this.Buffer, 0x10 + (num3 * 0x100), destinationArray, 0, 0x100);
                    this.myIDXformat = new IDXformat();
                    this.myIDXformat.ArrayToIDX(destinationArray, this.TXTpath);
                    if ((this.myIDXformat.UpdateTime == UpdateTime) && (this.myIDXformat.Title == Title))
                    {
                        this.Buffer[0x10 + (num3 * 0x100)] = 0x80;
                        flag = true;
                    }
                }
                num3++;
            }
            this.idxr.Close();
            this.idx.Close();
            this.idx  = new FileStream(this.IDXpath, FileMode.Create);
            this.idxw = new BinaryWriter(this.idx, Encoding.Default);
            this.idxw.Write(this.Buffer);
            this.idxw.Close();
            this.idx.Close();
            return(flag);
        }