Click here to Skip to main content
15,885,757 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[^]
 
Share this answer
 
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
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 :)
 
Share this answer
 
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