1

I tried to write file to xamarin forms and then copy to clipboard but i have no idea how can i copy file to clipboard any help will be appreciated.

string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "temp.txt");
            File.WriteAllText(fileName, "Hello Wolkhjkhjkrld");
            String file = "";
            using (StreamReader sr = new StreamReader(fileName))
            {
                file = sr.ReadToEnd();
            } 

So i want to copy that file to clipboard

Hristo Ivanov
  • 45
  • 1
  • 1
  • 7
  • Does this answer your question? [Copy files to clipboard in C#](https://stackoverflow.com/questions/211611/copy-files-to-clipboard-in-c-sharp) – Ryan Wilson Mar 06 '20 at 17:06

1 Answers1

2

use Xamarin Essentials Clipboard

await Clipboard.SetTextAsync("Hello World");

var text = await Clipboard.GetTextAsync();
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Yes but thats will work only for text but for example if i want to copy .html file? – Hristo Ivanov Mar 06 '20 at 17:30
  • an html file is just text. But generally you don't copy and paste files on mobile devices. You can share files, but that does not use the clipboard. – Jason Mar 06 '20 at 17:50