I am writing a C # Windows Universal App where a user can copy a file to the clipboard. But if the application is closed, the contents of the clipboard are lost. Usability is terrible if the user can easily lose the contents of the clipboard. Is there a way to make the contents of the application clipboard persistent, as in any other classic Windows application?
Code example:
public static void CopyFileToClipboard(StorageFile file) { DataPackage dp = new DataPackage(); dp.RequestedOperation = DataPackageOperation.Copy; dp.SetStorageItems(new List<StorageFile>() { file }); Clipboard.SetContent(dp);
So the question is, how can I put a file on the clipboard so that users can paste it even if the application is closed?
Edit: It seems that this is a problem for all Windows Universal Apps, for example, if you copy a picture in the Windows Photo application, it can only be inserted when the Photos application is running. I cannot imagine that this strange behavior should be the standard behavior of applications. This is more like a mistake, because I see no reason for this strange behavior.
Edit2: A new example of the problem (thanks to Joe300 for the feedback). It works with strings, but not with StorageFile (even if it is first copied to the local application folder). What is the reason that the Flush () command does not work with files? Is there something special to consider when files are used (permissions, ...)?
c # windows-10 windows-runtime uwp win-universal-app
ctron
source share