0

How can we implement the .net core file watcher program to watch the GCP directory(filestore). means the program can able to track the changes for particular directory.

nani
  • 15
  • 2
  • 6
  • have you tried `FileSystemWatcher` class. chek here https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=netcore-3.1 – Arjun Vachhani May 11 '20 at 05:36
  • @ArjunVachhani can we implement FileSystemWatcher for GCP FIlestore? – nani May 11 '20 at 05:38

1 Answers1

0

The .NET FileSystemWatcher can only watch the directories in a storage / directory managed by the Windows / Linux / Max OS. In a cloud scenario, and particularly the goolge cloud filestore is a managed service and there is no way you can use the FileSystemWatcher API to manage it. They both are called "directories" but doesn't mean they are same. The underlying mechanism to store and represent the structure is a lot different. You probably have to look into the API's in Google Cloud to do what you are looking for.

Soundararajan
  • 2,000
  • 21
  • 23
  • Ok I understand.I think if we are able to access the Filestore Mount directory, We can able to watch manually using the C# program to check the directory for every 30 min, etc.as per my requirement I need to check the directory contains particular file or not in every 30 minutes.that's it. – nani May 11 '20 at 07:33
  • Ok, I get your point. Were you able to mount it and use it from your file explorer / shell ? If so how did you manage permissions between the remote mount in GCP and your client. Did you entered password / credentials for the first time / – Soundararajan May 11 '20 at 07:48
  • Besides, why do you want a filesystem watcher if you are going to do a scan every 30 minutes. Can't you just scan the directory for the file with a regex filter and do it. FileSystemWatcher is for async scenarios, where they will callback on file arrival. But in your case you are going to poll anyways. – Soundararajan May 11 '20 at 07:49
  • Yes, the File watcher system is no need for my requirement. I am new to the Cloud environment.I didn't use any authentication for now.just using SSH Window to open Compute engine created sample .net core app and written simple C# code to get files from Mount point. – nani May 11 '20 at 08:17
  • Yes, it's working. I can able to access the mount directory because sample application is deployed in a machine that has a mount point already added .what if we deployed this application in another machine that doesn't have access.Need to check which auth need to implement for GCP in .Net core either SSH or username and password etc. – nani May 11 '20 at 08:24
  • For Permissions, perhaps you can try this. https://www.codeproject.com/Articles/43091/Connect-to-a-UNC-Path-with-Credentials – Soundararajan May 11 '20 at 08:31
  • Ok Soundararajan – nani May 11 '20 at 09:32
  • In order to mount the Filestore shared file system in a machine outside GCP or in a Compute Engine instance in a different VPC network, you can follow this [official documentation](https://cloud.google.com/filestore/docs/remote-mounting) – Jose V May 12 '20 at 10:15