Modifying, adding, or deleting certain types of files within the application's known folders will cause the application to restart.But when Log file in application is updated,why application is not restart. Then
PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
object o = p.GetValue(null, null);
FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
object monitor = f.GetValue(o);
MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
m.Invoke(monitor, new object[] { });
With these changes, I can create/modify/delete folders without causing the application to restart. But this code is for all application's known folders.I want to know is for one folder without causing the application restart.
Your problem is because as soon as you modify, or delete any file from the applications directory, it is causing appDomain restart in order to load the changes. You got 4 options as far as I could look for:
The above method is take from here
Also, you can go through the following links for more information:
Well, this might be able to help with your issue, I could not find out anything about stopping the appDomain change monitoring for a specific folder. Either it would monitor the changes or not. Hope this helps. Cheers.