FileWatcher for project folder
anyone have better idea how to listen for changes in project folder? i have text file in this folder and i want to listen for changes
19 Replies
You are already using the right tool for it,
FileSystemWatcher
, what would you like to improve?Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
i just posted minimal code, i'm attaching events.
i want to refactor this:
string outputDirectory = AppDomain.CurrentDomain.BaseDirectory;
string projectDirectory = Directory.GetParent(outputDirectory).Parent.Parent.Parent.FullName; // Navigate to the project folder
Is there any magic variable like "ProjectPath"?
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
project where .csproj file is
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Because next to this file is my "file.txt" i want to watch using file watcher
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
this is not config file, rather script
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
But i want at runtime know when file changed
And this is not config file... i can't use appsettings
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
file structure looks like this
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
When i run project it run it in different folder than project
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yes
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
you dont typically ship the source code with the app
just put the file in the output directory and read from AppContext.BaseDirectory