I’m working on a Windows desktop app in C# that saves data in a custom file format. We’ve run into issues with file corruption when users save to Google Drive and it syncs. Now I’m trying to prevent users from saving to Google Drive folders.
The tricky part is figuring out if the save location is a Google Drive path. Since it’s an offline app, I can’t use Google Drive API. All checks need to work without an internet connection.
I’ve looked into some solutions online, but they didn’t pan out. For example, I tried to find a sync_config.db file in a specific location, but it wasn’t there.
Does anyone know a reliable method to detect Google Drive paths in C# without needing internet? Any help would be great!
hey, i’ve dealt with this before. one trick is to check for the presence of a ‘.tmp.drivedownload’ folder in the parent directory. Google Drive creates these for syncing. not foolproof, but it’s worked for me in offline scenarios. hope that helps!
I’ve encountered similar challenges with Google Drive syncing in my projects. One approach that’s proven effective is examining the file path for specific Google Drive-related patterns. Look for substrings like ‘Google Drive’, ‘GoogleDrive’, or ‘My Drive’ in the path. Additionally, you might consider checking for the presence of a ‘.gdoc’ file in the directory, which is often associated with Google Drive content. While not infallible, these methods can provide a reasonable heuristic for identifying Google Drive locations without relying on an internet connection. Remember to thoroughly test any solution across various system configurations to ensure reliability.
I’ve grappled with this issue in my own projects, and it’s a tricky one. One method I’ve found somewhat reliable is checking for the presence of a ‘.shortcut-targets-by-id’ folder in the root of the Google Drive directory. This folder is typically created by Google Drive for managing shortcuts.
Another approach is to look for specific file naming patterns that Google Drive uses for conflicting files, like ‘(1)’, ‘(2)’, etc. at the end of filenames. These are often indicators of Google Drive’s sync behavior.
Keep in mind, though, that these methods aren’t foolproof. Google Drive’s structure can change, and users might rename folders. It might be worth considering a combination of checks for more accuracy.
Alternatively, you could implement a warning system that alerts users about potential sync issues when saving, rather than outright preventing saves to certain locations. This puts the decision in the user’s hands while still addressing the concern.