-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileSystemWatcher to a directory symlink that points to a file doesn't raise exception on windows 8.1 or lower #53010
Comments
Tagging subscribers to this area: @carlossanlop Issue DetailsDescriptionOn cmd: # create file
echo text > file.txt
# create directory symlink to file
mklink /d linktofile file.txt On .NET: using System;
using System.IO;
namespace fsw
{
class Program
{
static void Main(string[] args)
{
using var watcher = new FileSystemWatcher("linktofile");
watcher.EnableRaisingEvents = true; // This should've thrown.
Console.WriteLine("Watching...");
Console.ReadKey();
}
}
} Configuration.NET 5 and .NET 6 preview Regression?No Other informationThe only problem I see is consistency.
|
Were you able to determine the root cause? |
See related https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew#directories. |
Thanks. So if those Windows versions do not throw, are you suggesting we detect the self-referencing dir symlink ourselves? |
Yes, it could be an option. We most probably want to only do that for those versions and avoid the manual validation (potentially involves a sys-call) in win10, which currently throws as expected. Another option is to find an alternative API that throws in such case and that also returns a handle for a directory, not sure if exists. |
Description
On cmd:
On .NET:
Configuration
.NET 5 and .NET 6 preview
OS: Windows 8.1 or 7.
Windows 10 throws which is what I expected since a directory symlink to a file is a bad symlink.
Regression?
No
Other information
The only problem I see is consistency.
cc @carlossanlop
The text was updated successfully, but these errors were encountered: