Click here to Skip to main content
15,074,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thanks in advance..... I need to capture the chrome profile path through programmatically. Now I am using the code like this....

string google = @"C:\Google\Chrome\User Data\Default\History"

But I need not want like this because In my system the history saved in default path folder and other user system the history store in profile1 folder like wise the folder name changes. So I need to get the full profile path programmatically using c#.net....Pls give some idea...

What I have tried:

String sourceFile1 = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\";
Posted
Updated 24-Mar-21 4:39am
v2

I think this will do:
var chromePath = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
chromePath += @"\Local\Google\Chrome\User Data\Default";

Another option is to use Selenium: Profile Example, C# - rextester[^]
   
v4
Comments
Member 15028582 29-Jan-21 3:39am
   
ji.....How can use this chrome://version in my windows form is my question.....pls give some example code ji
Member 15028582 29-Jan-21 4:19am
   
Ji.....I get the error in ProcessRun....what should I do...pls guide ji
RickZeeland 29-Jan-21 4:29am
   
Sorry about that, it should be:
System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", arguments);
But that does not seem to work either ...
Member 15028582 29-Jan-21 4:39am
   
Actually it opens a new chrome browser not showing the chrome://version path details....Pls help
Member 15028582 29-Jan-21 4:43am
   
ji....I need to capture the chrome://version ---> Chrome profile path in textbox...Is this possible
Member 15028582 1-Feb-21 23:11pm
   
Ji....I need to capture this path programatically chromePath += @"\Local\Google\Chrome\User Data\Default"; only ji....This should not be in hardcode format...
RickZeeland 2-Feb-21 1:18am
   
I think the last part of the path will probably be the same, but you should test that on different machines to be sure.
Member 15028582 2-Feb-21 5:36am
   
No ji....In My system the history file store in default folder but in some other system the history file is store in profile1 folder likewise the folder changing for every system...so that only I need to capture the subfolders also by code....Is there any idea ji....I have googled a lot but I didn't get any solution..
RickZeeland 2-Feb-21 5:39am
   
Bummer :(
Member 15028582 2-Feb-21 6:01am
   
Is there any idea ji...
A bit late to the party, but in case you or someone else are struggling... :)

As you've already found out, you can't blindly trust the correct Chrome profile to be in the Default sub-directory. A user can make several Chrome profiles having different configurations of add-ins, bookmarks, etc., etc... I'm not sure why I'm not using the Default profile either, but I'm not...

However, in the Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Google\Chrome\User Data") directory you'll find a file named "Local State".

This file contains, amongst a lot of other things, information like:
...,"last_active_profiles":["Profile 1"],...

The "last_active_profiles":"..." should give you the sub-directory you're looking for.

On my machine it's as above, but on a different machine the setting is:
...,"last_active_profiles":["Default"],...

So, all you need to do is loading this text file, search to find this key and identify the following value :)
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900