0
我想在文件名中使用掩碼將ext文件應用於一組文件,在文件夾C:\ TMP中的所有txt文件上:.net - 在文件名中使用帶有掩碼的FileIOPermission
[type: FileIOPermission(SecurityAction.PermitOnly, Read = @"C:\TMP\*.txt")]
class SomeClass
{
static void testPermissions()
{
Console.WriteLine("allowed action");
File.OpenRead(@"C:\TMP\1.txt"); // <--- here goes exception
Console.WriteLine("denied action");
try
{
File.Create(@"C:\TMP\2.txt");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.ReadKey();
}
}
}
This throws ArgumentException「Illegal characters in path。」
出了什麼問題?無論如何可以實現嗎?