S
schaf
Hi NG !
I have the following piece of code below. the first try/catch part
would return true although I do not have permission to access this
computer. The second try/catch part would return false.
Do I misunderstand the meaning of FileIOPermission ?
Thanks for education!
Regards Marcel (Schaf)
private bool _HasRemoteAccess() {
string sRemotePath = @"\\192.168.2.2\C$\Temp\Text.txt";
bool bHasAccess = true;
//returns true
try {
FileIOPermission permission = new
FileIOPermission(FileIOPermissionAccess.Write, sRemotePath);
permission.Demand();
} catch (System.Security.SecurityException se) {
bHasAccess = false;
}
//returns false
try {
string[] sRemoteFiles = Directory.GetFiles(sRemotePath);
} catch (Exception e) {
bHasAccess = false;
}
return bHasAccess;
}
I have the following piece of code below. the first try/catch part
would return true although I do not have permission to access this
computer. The second try/catch part would return false.
Do I misunderstand the meaning of FileIOPermission ?
???From MSDN: "Controls the ability to access files and folders"
Thanks for education!
Regards Marcel (Schaf)
private bool _HasRemoteAccess() {
string sRemotePath = @"\\192.168.2.2\C$\Temp\Text.txt";
bool bHasAccess = true;
//returns true
try {
FileIOPermission permission = new
FileIOPermission(FileIOPermissionAccess.Write, sRemotePath);
permission.Demand();
} catch (System.Security.SecurityException se) {
bHasAccess = false;
}
//returns false
try {
string[] sRemoteFiles = Directory.GetFiles(sRemotePath);
} catch (Exception e) {
bHasAccess = false;
}
return bHasAccess;
}