What i am trying to do is to change the default homepage for Mozilla Firefox, I know that the homepage is stored in the following path ( In my computer )
C:\\Users\\JohnnyB\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\jmwb4bnw.default\\prefs.js
The problem is that the jmwb4bnw.default
folder has a different name in each computer, which may lead my file to not work on other computer due to different folder name. For me, everything is Ok, but for other computer it doesn't work because of the wrong file path.
My question is how can i access the jmwb4bnw.default
folder regardless to it's current name, this folder is a unique folder under Profiles folder.
The snippest code i am using is: (It works only on my computer)
string ff_filepath = "C:\\Users\\Sandbox\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\jmwb4bnw.default\\prefs.js";
string myLine = "user_pref('browser.startup.homepage', 'www.monde-presse.com');";
StreamWriter sw;
sw = File.AppendText(ff_filepath);
sw.WriteLine(myLine);
sw.Close();
How to make the code above works on every computer ?
Or in such language, how to tell C# to access the jmwb4bnw.default
folder regardless to it's name..
Note : The \Profiles\ folder contain no files, and Only one folder named jmwb4bnw.default
, maybe there is someway to tell C# to access the subfolder which is found on Profiles folder regardless to it's current name ?
Finally : How can i make the above code snippest to work on every Computer ?
(In the example above, we assume that default drive is always C, and user profile is always JohnnyB)