本文整理汇总了C#中System.Security.Permissions.FileIOPermission.GetPathList方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.GetPathList方法的具体用法?C# FileIOPermission.GetPathList怎么用?C# FileIOPermission.GetPathList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.FileIOPermission
的用法示例。
在下文中一共展示了FileIOPermission.GetPathList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShortToLong
public void ShortToLong ()
{
// on windows this returns a "short" (8.3) path and filename
string filename = Path.GetTempFileName ();
p = new FileIOPermission(FileIOPermissionAccess.Read, filename);
string[] files = p.GetPathList (FileIOPermissionAccess.Read);
Assert.AreEqual (1, files.Length, "GetPathList.Count");
// FIXME: here GetTempFileName != GetPathList[0] for MS but == for Mono
Assert.AreEqual (Path.GetFileName (filename), Path.GetFileName (files [0]), "Path.GetFileName(GetTempFileName)==Path.GetFileName(GetPathList[0])");
// note: this will fail on Linux as kernel32.dll isn't available
Assert.AreEqual (FilePathUtil.GetLongPathName (filename), files [0], "GetLongPathName(GetTempFileName)==GetPathList[0]");
}
示例2: FromXML
public void FromXML ()
{
p = new FileIOPermission(PermissionState.None);
SecurityElement esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
esd.AddAttribute("Unrestricted", "true");
p.FromXml(esd);
Assert.IsTrue(p.IsUnrestricted(), "Should get an unrestricted permission");
esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
// FIXME: Adjust to run on Mac OS's
if (Path.VolumeSeparatorChar == ':') {
esd.AddAttribute("Read", "c:\\temp;d:\\temp2");
esd.AddAttribute("Write", "c:\\temp;d:\\temp2;z:\\temp3");
}
else {
esd.AddAttribute("Read", "/temp;/usr/temp2");
esd.AddAttribute("Write", "/temp;/usr/temp2;/usr/bin/temp3");
}
p = new FileIOPermission(PermissionState.None);
p.FromXml(esd);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(pathsInPermission.Length == 2, "Path list should have 2 for Read");
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Write);
Assert.IsTrue(pathsInPermission.Length == 3, "Path list should have 2 for Write");
}
示例3: ConstructorString
public void ConstructorString ()
{
string pathToAdd;
// FIXME: Adjust to run on Mac OS's
if (Path.VolumeSeparatorChar == ':')
pathToAdd = "c:\\temp";
else
pathToAdd = "/temp";
p = new FileIOPermission(FileIOPermissionAccess.Read, pathToAdd);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue (pathsInPermission.Length == 1, "Does not contain correct number of paths. Expected 1 but got: "+pathsInPermission.Length);
Assert.IsTrue(pathsInPermission[0] == pathToAdd, "Does not contain expected path from constructor: "+pathToAdd);
}
示例4: AddPathListStringArray
public void AddPathListStringArray ()
{
p = new FileIOPermission(FileIOPermissionAccess.Read, pathArrayGood);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue (pathsInPermission.Length == 2, "Does not contain correct number of paths. Expected 2 but got: "+pathsInPermission.Length);
foreach (string s in pathsInPermission){
Assert.IsTrue (Array.IndexOf(pathsInPermission, s) >=0, "Unexpected path in the Permission: " + s);
}
p.AddPathList(FileIOPermissionAccess.Append, pathArrayGood);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue (pathsInPermission.Length == 2, "Should still contain correct number Read paths. Expected 2 but got: "+pathsInPermission.Length);
foreach (string s in pathsInPermission){
Assert.IsTrue (Array.IndexOf(pathsInPermission, s) >=0, "Unexpected path in the Permission: " + s);
}
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Append);
Assert.IsTrue (pathsInPermission.Length == 2, "Should contain correct number of Append paths. Expected 2 but got: "+pathsInPermission.Length);
foreach (string s in pathsInPermission){
Assert.IsTrue (Array.IndexOf(pathsInPermission, s) >=0, "Unexpected path in the Permission: " + s);
}
}
示例5: ConstructorStringArray
public void ConstructorStringArray ()
{
p = new FileIOPermission(FileIOPermissionAccess.Read, pathArrayGood);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert("Does not contain correct number of paths. Expected 2 but got: "+pathsInPermission.Length, pathsInPermission.Length == 2);
foreach (string s in pathsInPermission){
Assert("Unexpected path in the Permission: " + s, Array.IndexOf(pathsInPermission, s) >=0);
}
}