本文整理汇总了C#中FileAccess.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# FileAccess.ToString方法的具体用法?C# FileAccess.ToString怎么用?C# FileAccess.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileAccess
的用法示例。
在下文中一共展示了FileAccess.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateAccess
protected void ValidateAccess(FileAccess access)
{
if (!_access.HasFlag(access))
{
throw new InvalidOperationException($"The current {GetType().Name} does not support {access.ToString("G")} access.");
}
}
示例2: TestMethod
private MFTestResults TestMethod(FileMode fm, FileAccess fa)
{
Log.Comment("Starting tests in FileMode: " + fm.ToString() + " with FileAccess: " + fa.ToString());
int iCountErrors = 0;
String fileName = "TestFile";
StreamWriter sw2;
FileStream fs2;
String str2;
if (File.Exists(fileName))
File.Delete(fileName);
Log.Comment("File does not exist");
//------------------------------------------------------------------
switch (fm)
{
case FileMode.CreateNew:
case FileMode.Create:
case FileMode.OpenOrCreate:
try
{
Log.Comment("null path");
fs2 = File.Open(null, fm, fa);
if (!File.Exists(fileName))
{
iCountErrors++;
Log.Exception("File not created, FileMode==" + fm.ToString());
}
fs2.Close();
}
catch (ArgumentException aexc)
{
Log.Comment("Caught expected exception, aexc==" + aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
Log.Exception("Incorrect exception thrown, exc==" + exc);
}
try
{
Log.Comment("string empty path");
fs2 = File.Open("", fm, fa);
if (!File.Exists(fileName))
{
iCountErrors++;
Log.Exception("File not created, FileMode==" + fm.ToString());
}
fs2.Close();
}
catch (ArgumentException aexc)
{
Log.Comment("Caught expected exception, aexc==" + aexc.Message);
}
catch (Exception exc)
{
iCountErrors++;
Log.Exception("Incorrect exception thrown, exc==" + exc);
}
try
{
Log.Comment("string:" + fileName);
fs2 = File.Open(fileName, fm, fa);
if (!File.Exists(fileName))
{
iCountErrors++;
Log.Exception("File not created, FileMode==" + fm.ToString());
}
fs2.Close();
}
catch (ArgumentException aexc)
{
if ((fm == FileMode.Create && fa == FileAccess.Read) || (fm == FileMode.CreateNew && fa == FileAccess.Read))
{
Log.Comment("Caught expected exception, aexc==" + aexc.Message);
}
else
{
iCountErrors++;
Log.Exception("Unexpected exception, aexc==" + aexc);
}
}
catch (Exception exc)
{
iCountErrors++;
Log.Exception("Incorrect exception thrown, exc==" + exc);
}
break;
case FileMode.Open:
case FileMode.Truncate:
try
{
Log.Comment("null path");
fs2 = File.Open(null, fm, fa);
iCountErrors++;
Log.Exception("Expected exception not thrown");
fs2.Close();
}
//.........这里部分代码省略.........
示例3: Init
private void Init(XPathDocument xpDoc, FileAccess mode, bool strict, params string[] pageNames)
{
if (mode != FileAccess.Read) throw new IOException(mode.ToString() + " not supported");
XsltArgumentList xslArgs = new XsltArgumentList();
if (pageNames.Length > 0) {
string pageNameList = "|";
foreach(string pageName in pageNames) pageNameList += (pageName + "|");
xslArgs.AddParam("selected-pages", String.Empty, pageNameList);
}
xslArgs.AddParam("strict", String.Empty, strict?"true":"false");
XslCompiledTransform xslt = Xml.GetCachedCompiledTransform("visio2003toRuleML.xsl");
MemoryStream stream = new MemoryStream();
xslt.Transform(xpDoc, xslArgs, stream);
stream.Seek(0, SeekOrigin.Begin);
ruleBaseAdapter = new RuleML09NafDatalogAdapter(stream, FileAccess.Read);
}
示例4: AbstractRuleMLAdapter
/// <summary>
/// Instantiates a RuleML adapter for reading or writing to an URI.
/// In Read mode, the adapter tries to locate a flow engine binder definition file
/// by appending .xbre to the URI.
/// </summary>
/// <param name="uriRuleML">The URI to read rules from or write to.</param>
/// <param name="mode">The FileAccess mode.</param>
public AbstractRuleMLAdapter(string uriRuleML, FileAccess mode)
{
if (uriRuleML == null) throw new ArgumentNullException("A null URI is invalid");
if ((mode != FileAccess.Read) && (mode != FileAccess.Write)) throw new IOException(mode.ToString() + " not supported");
}
示例5: Init
private void Init(XPathDocument xpDoc, FileAccess mode, bool strict, params string[] pageNames)
{
if (mode != FileAccess.Read) throw new IOException(mode.ToString() + " not supported");
XsltArgumentList xslArgs = new XsltArgumentList();
if (pageNames.Length > 0) {
string pageNameList = "|";
foreach(string pageName in pageNames) pageNameList += (pageName + "|");
xslArgs.AddParam("selected-pages", String.Empty, pageNameList);
}
XslTransform xslt = new XslTransform();
// select the appropriate XSL
string xslName = strict?"strict-vdx2nxbre-ie.xsl":"vdx2nxbre-ie.xsl";
xslt.Load(new XPathDocument(Assembly.GetExecutingAssembly().GetManifestResourceStream(Parameter.GetString(xslName, xslName))),
null,
null);
MemoryStream stream = new MemoryStream();
xslt.Transform(xpDoc, xslArgs, stream, null);
stream.Seek(0, SeekOrigin.Begin);
rml086da = new RuleML086NafDatalogAdapter(stream, FileAccess.Read);
}
示例6: RuleML086NafDatalogAdapter
/// <summary>
/// Instantiates a RuleML 0.86 Datalog adapter for reading or writing to an URI.
/// In Read mode, the adapter tries to locate a flow engine binder definition file
/// by appending .xbre to the URI.
/// </summary>
/// <param name="uriRuleML">The URI to read rules from or write to.</param>
/// <param name="mode">The FileAccess mode.</param>
public RuleML086NafDatalogAdapter(string uriRuleML, FileAccess mode, bool supportTypedFacts) {
if (uriRuleML == null) throw new ArgumentNullException("A null URI is invalid");
if ((mode != FileAccess.Read) && (mode != FileAccess.Write)) throw new IOException(mode.ToString() + " not supported");
this.supportTypedFacts = supportTypedFacts;
Init(null, uriRuleML, mode);
}