Skip to content

Commit f7db5ad

Browse files
committed
🐛 fixed #112
Implemented new check for Google Drive folder, probably needs testing, but should fit most cases (not sure when using a different language for GDrive than English... We'll see)
1 parent 448bcc4 commit f7db5ad

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

AssistantComputerControl/CloudServiceFunctions.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,42 @@ public static bool GoogleDriveInstalled() {
3232
return GetGoogleDriveFolder() != String.Empty;
3333
}
3434
public static string GetGoogleDriveFolder() {
35-
string registryKey = @"Software\Google\Drive";
35+
//New Google Drive check first
36+
string registryKey = @"Software\Google\DriveFS";
3637
RegistryKey key = Registry.CurrentUser.OpenSubKey(registryKey);
38+
39+
if (key != null || Directory.Exists(Environment.ExpandEnvironmentVariables("%programfiles%") + @"\Google\Drive File Stream")) {
40+
//New google Drive seems to be installed
41+
DriveInfo[] allDrives = DriveInfo.GetDrives();
42+
43+
//Check if it's a virual drive
44+
foreach (DriveInfo d in allDrives) {
45+
if (d.VolumeLabel == "Google Drive") {
46+
string check = Path.Combine(d.Name, "My Drive");
47+
if (Directory.Exists(check)) {
48+
return check;
49+
}
50+
}
51+
}
52+
53+
//Not a virtual drive, check the user's folder
54+
string userDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
55+
if (Directory.Exists(userDir)) {
56+
foreach (string dir in Directory.GetDirectories(userDir)) {
57+
if (dir.Contains("My Drive")) {
58+
//Pretty sure it's Google Drive... But bad practice maybe...?
59+
return dir;
60+
}
61+
}
62+
}
63+
64+
65+
return "partial";
66+
}
67+
68+
//No? Check the old one
69+
registryKey = @"Software\Google\Drive";
70+
key = Registry.CurrentUser.OpenSubKey(registryKey);
3771
if (key != null) {
3872
string installed = key.GetValue("Installed").ToString();
3973
key.Close();

0 commit comments

Comments
 (0)