0

How can I read a file as sudo/admin on Mac in C# (xamarin.Mac)

I made a File in /usr/ and I cant read it with:

string text = system.io.file.ReadallText("/usr/file"); 

it doesn't seam to have access to the file.

EDIT: It needs to be from within the Program

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Dr.Net
  • 53
  • 6
  • 1
  • Check for directory permissions – Abdul Manan Nov 27 '17 at 13:50
  • If you could access files (without user intervention) that you do not have access to it wouldn't be a very secure operating system IMO. It sounds to me like you have a design flaw in your program. Either write to a folder that you are allowed to access or elevate your program to read an otherwise inaccessible file. – default Nov 27 '17 at 14:10
  • I cant find anything in the Xamarin Guide how to Elevate the Program. is it from the info.plist? – Dr.Net Nov 27 '17 at 14:27
  • https://developer.apple.com/library/content/documentation/Security/Conceptual/SecureCodingGuide/Articles/AccessControl.html – SushiHangover Nov 27 '17 at 21:07

0 Answers0