Using VirtualFileDataObject

Heiko 1,261 Reputation points
2021-07-20T11:21:56.037+00:00

I want to be able to stream data into another app and stream it from another app into my app via the clipboard or by drag and drop. To do this, I am using the VirtualFileDataObject class that I downloaded from here. There is also a demo app on the web page that allows you to stream data to another app using the DataObject contents "FileGroupDescriptorW" and "FileContents".

Unfortunately, copying or drag and drop does not work with every app. If you copy data to Windows Explorer via the clipboard, it works. The data is copied as a file to the destination directory.

However, when I want to receive the data copied with 'VirtualFileDataObject' from the clipboard, the stream is empty. in the debugger I can see that I am reading the stream in my app and I get 0 bytes. At the same time, in the debugger of the sending demo app, I can see that data is being written to the stream there, but it never arrives in my app.

To receive the data I use the code from here.

Does anyone have experience with this and know how to solve the problem?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,027 questions
{count} votes

Accepted answer
  1. RLWA32 45,701 Reputation points
    2021-07-20T17:03:46.3+00:00

    Are you rewinding the stream in the receiving app to its beginning before you attempt to read it?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.