Skip to content

FileSystemWatcher to a directory symlink that points to a file doesn't raise exception on windows 8.1 or lower #53010

@jozkee

Description

@jozkee

Description

On 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
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions