当前位置: 首页>>代码示例>>C#>>正文


C# FileIOPermission.GetPathList方法代码示例

本文整理汇总了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]");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:12,代码来源:FileIOPermissionTest.cs

示例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");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:29,代码来源:FileIOPermissionTest.cs

示例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);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:14,代码来源:FileIOPermissionTest.cs

示例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);
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:21,代码来源:FileIOPermissionTest.cs

示例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);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:FileIOPermissionTest.cs


注:本文中的System.Security.Permissions.FileIOPermission.GetPathList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。