1

Firefox履歴ファイルのパスにはプロファイル番号が含まれています.C#でこの番号を動的に取得するにはどうすればよいですか

C:\Users\\AppData\Roaming\Mozilla\Firefox\Profiles\.default\formhistory.sqlite

4

3 に答える 3

1

profile.ini ファイルを読み込んで、デフォルトのプロファイルを取得する必要があります

using System;
using System.Linq;
using System.IO;

namespace Firefox
{
    class Reader
    {
        public static string ReadFirefoxProfile()
        {
            string apppath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            string mozilla = System.IO.Path.Combine(apppath, "Mozilla");

            bool exist = System.IO.Directory.Exists(mozilla);

            if (exist)
            {

                string firefox = System.IO.Path.Combine(mozilla, "firefox");

                if (System.IO.Directory.Exists(firefox))
                {
                    string prof_file = System.IO.Path.Combine(firefox, "profiles.ini");

                    bool file_exist = System.IO.File.Exists(prof_file);

                    if (file_exist)
                    {
                        StreamReader rdr = new StreamReader(prof_file);

                        string resp = rdr.ReadToEnd();

                        string[] lines = resp.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                        string location = lines.First(x => x.Contains("Path=")).Split(new string[] { "=" }, StringSplitOptions.None)[1];

                        string prof_dir = System.IO.Path.Combine(firefox, location);

                        return prof_dir;
                    }
                }
            }
            return "";
        }
    }
}
于 2014-09-02T11:37:41.397 に答える
1

すべての firefoxprofile のプロファイル名を含む次の ini ファイルを読み取ることができます。

"C:\Users\Username\AppData\Roaming\Mozilla\Firefox\profiles.ini"
于 2013-08-22T09:28:13.247 に答える
-1

Windows の [スタート] ボタンをクリックし、%APPDATA%\Mozilla\Firefox\Profiles\Enter キーを押さずに、[スタート] メニューの下部にある検索ボックスに入力します。プロファイルのリストが [スタート] メニューの上部に表示されます。
名前に「default」が含まれるプロファイルをクリックして、ウィンドウで開きます。

于 2013-08-22T11:19:55.757 に答える