Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. NSUrl tmpFolder = NSFileManager.DefaultManager.GetTemporaryDirectory();
  2. var tmpFileUrl = tmpFolder.Append(originalFileName, false);
  3. // create a temporary file with the original filename instead of id.jpg (e.g. 3242.jpg -> pump_module.jpg)
  4. NSError copyError;
  5. NSFileManager.DefaultManager.Copy(fileUrl, tmpFileUrl, out copyError);
  6. // if there was no error copying or the file already existed before copy
  7. if (copyError == null || NSFileManager.DefaultManager.FileExists(tmpFileUrl.Path))
  8. {
  9. // the file in the tmp folder has the correct filename
  10. shareFile = tmpFileUrl;
  11. }
  12. else
  13. {
  14. // on error fall back to the former name
  15. shareFile = fileUrl;
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement