public static FileStream OpenFileStream(string fileName, FileMode fileMode, FileAccess fileAccess, FileShare fileShare) { if (fileName.Length <= 260) { return(new FileStream(fileName, fileMode, fileAccess)); } var handle = CreateFile( @"\\?\" + fileName, fileAccess.Convert(), fileShare.Convert(), IntPtr.Zero, fileMode.Convert(), 0, IntPtr.Zero); var stream = new FileStream(handle, fileAccess); if (fileMode == FileMode.Append) { stream.Seek(0, SeekOrigin.End); } return(stream); }