🟣 C# / .NET 6+
Enable Win32 Long Paths (C#)
Lifts the legacy 260-character MAX_PATH limit for apps that opt in (requires admin). Requires an elevated (Administrator) prompt. Applies the tweak via Microsoft.Win32.Registry.
SetEnableLongPaths.cs
// SetEnableLongPaths.cs
//
// Enable Win32 Long Paths.
// Lifts the legacy 260-character MAX_PATH limit for apps that opt in (requires admin). Requires an elevated (Administrator) prompt.
//
// Usage: dotnet new console -o SetEnableLongPaths, replace Program.cs with this
// file, then dotnet run.
using System;
using Microsoft.Win32;
using RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\FileSystem");
key.SetValue("LongPathsEnabled", 1, RegistryValueKind.DWord);
Console.WriteLine("Enable Win32 Long Paths applied.");