8000 DataObject.GetData(DataFormats.FileDrop) raises an exception when trying to get a long-path file · Issue #10471 · dotnet/wpf · GitHub
[go: up one dir, main page]

Skip to content
DataObject.GetData(DataFormats.FileDrop) raises an exception when trying to get a long-path file #10471
@neelabo

Description

@neelabo

Description

An error occurs when I try to accept a long path file (>256 characters?) from Explorer by drag and drop.
DataObject.GetData(DataFormats.FileDrop)

The data area passed to a system call is too small. (0x8007007A)

Reproduction Steps

1. Prepare a long-path file.

For example, a folder with a path length of 240 characters is created by creating a folder and copying a file with a 50-character filename into it.

2. WPF to accept file drops and use the following method to retrieve FileDrop data.

string[]? GetFileDrop(System.Windows.DataObject data)
{
    if (data.GetDataPresent(DataFormats.FileDrop))
    {
        return (string[])data.GetData(DataFormats.FileDrop);
    }
    else
    {
        return null;
    }
}

3. Dropping a long-path file from Explorer to this app will cause an exception.

Expected behavior

Even long-path files receive drops without problems.

Actual behavior

Error message:

例外がスローされました: 'System.Runtime.InteropServices.COMException' (PresentationCore.dll の中)
システム コールに渡されるデータ領域が小さすぎます。 (0x8007007A)

Stack trace:

[マネージドからネイティブへの移行]	
PresentationCore.dll!System.Windows.DataObject.OleConverter.GetDataFromOleHGLOBAL(string format, System.Runtime.InteropServices.ComTypes.DVASPECT aspect, int index)	不明
PresentationCore.dll!System.Windows.DataObject.OleConverter.GetData(string format, bool autoConvert, System.Runtime.InteropServices.ComTypes.DVASPECT aspect, int index)	不明
PresentationCore.dll!System.Windows.DataObject.GetData(string format, bool autoConvert)	不明
C
635A
lipboardWatch.dll!ClipboardWatch.MainWindow.GetFileDrop(System.Windows.DataObject data) 行 93	C#
:

The error also occurs via the clipboard.
The error message is different, but the stack trace is the same.

例外がスローされました: 'System.Runtime.InteropServices.COMException' (PresentationCore.dll の中)
クリップボードのデータが無効です (0x800401D3 (CLIPBRD_E_BAD_DATA))

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

  • .NET9
  • Windows10, x64

Other information

I found that ReadFileListFromHandle() in PresentationCore/System/Windows/dataobject.cs allocates a buffer with MAX_PATH. This may have something to do with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateRequires further investigation by the WPF team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0