Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // This is NOT best-practice code, just showing a demo of an Jcifs api call
  2. public async Task getFileContents ()
  3. {
  4. await Task.Run (() => {
  5. var smbStream = new SmbFileInputStream ("smb://guest@10.10.10.5/code/test.txt");
  6. byte[] b = new byte[8192];
  7. int n;
  8. while ((n = smbStream.Read (b)) > 0) {
  9. Console.Write (Encoding.UTF8.GetString (b).ToCharArray (), 0, n);
  10. }
  11. Button button = FindViewById<Button> (Resource.Id.myButton);
  12. RunOnUiThread(() => {
  13. button.Text = Encoding.UTF8.GetString (b);
  14. });
  15. }
  16. ).ContinueWith ((Task arg) => {
  17. Console.WriteLine (arg.Status);
  18. if (arg.Status == TaskStatus.Faulted)
  19. Console.WriteLine (arg.Exception);
  20. }
  21. );
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement