c# winfrom获取 本地 Cookies文件夹下txt文件可以,并且能读取到里面的信息内容,但是获取index.dat文件提示访问不了之类的说法,是什么原因??求解C#Cookie

解决方案 »

  1.   

    FileStream fs = new FileStream(filePath, FileMode.Open,FileAccess.Read, FileShare.ReadWrite);
    StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
    filePath换成index.dat文件路径即可读取
    完整的贴上来
     List<string> listCookie = new List<string>();
                string[] strCookies = null;
                RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", false);
                if (key != null)
                {
                    string val = (string)key.GetValue("Cookies");
                    if (val != null)
                    {
                        strCookies = Directory.GetFiles(val);
                        if (strCookies != null)
                        {
                            foreach (string str in strCookies)
                            {
                                if (str.Contains("index.dat"))
                                {
                                listCookie.Add(str);
                                }
                            }
                        }
                    }
                }
      

  2.   

    index.dat里面的文件格式怎么解析,什么编码格式?求解?
      

  3.   

    System.Text.Encoding.Default你看下是不是U8的
      

  4.   

    index.dat有特定的格式的,你可以上网查查,有很多关于index.dat格式读取的方法。我最近也在研究,发现在win7下的index.dat查看器都无法查看到最近的记录,不知什么原因。