本文整理汇总了C#中System.IO.StreamReader.Write方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.Write方法的具体用法?C# StreamReader.Write怎么用?C# StreamReader.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.Write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string fileIn = null;
string fileOut = null;
int exitCode = 0;
FileFormat input_type = FileFormat.Auto;
if (args.Length == 0)
{
usageHelp();
exitCode = 1;
}
else
{
foreach (string arg in args)
{
if (arg.StartsWith("-", StringComparison.InvariantCulture) ||
arg.StartsWith("/", StringComparison.InvariantCulture)
)
{
#region Process options
string[] option = arg.Substring(1).Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
string value = string.Empty;
if (option.Length == 2)
value = option[1].Trim();
switch (option[0].ToLowerInvariant())
{
case "hex":
input_type = FileFormat.Hex;
break;
case "bin":
input_type = FileFormat.Binary;
break;
case "jam":
input_type = FileFormat.Jam;
break;
case "mcu":
#region Set PIC type
switch (value.ToUpperInvariant())
{
case "PIC24FJ256":
Memory = new byte[256 * 1024];
break;
case "PIC24FJ128":
Memory = new byte[128 * 1024];
break;
default:
Console.WriteLine(string.Format("Unknown -mcu {0}", value));
exitCode = 1;
break;
}
break;
#endregion
case "b":
case "base":
#region Set base address
if (!string.IsNullOrEmpty(value))
{
if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
{ // Hex format 0x....
if (uint.TryParse(value.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out BaseAddress))
break;
}
else
{
if (uint.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out BaseAddress))
break;
}
}
exitCode = 1;
break;
#endregion
case "f":
case "fill":
#region Set empty memory value
if (!string.IsNullOrEmpty(value))
{
if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
{ // Hex format 0x
if (byte.TryParse(value.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out EmptyValue))
break;
}
else
{ // Decimal format
if (byte.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out EmptyValue))
break;
}
}
exitCode = 1;
break;
#endregion
case "s":
case "scan":
#region Set scan file only mode
ScanOnly = true;
break;
#endregion
default:
#region Unknown option
//.........这里部分代码省略.........
示例2: _GetSummary
private DocumentOutput _GetSummary(string root)
{
DocumentOutput doc = null;
/*verificam daca este deja documentul in bd*/
try {
doc = this._em.GetDocumentOutput(this._doc.DocumentId, "summ");
/*ne asiguram ca este scris*/
using (Stream stream = File.OpenWrite(root + "\\summ.xml")) {
byte[] buffer = Encoding.UTF8.GetBytes(doc.Document);
stream.Write(buffer, 0, buffer.Length);
}
} catch { }
if (doc != null)
return doc;
String input = null;
using (StreamReader stream = new StreamReader(root + "\\main.txt")) {
input = stream.ReadToEnd();
}
/*cream modulu de sumarizare*/
/*ISummarizer summarizer = new SimpleSummarizer();
String output = summarizer.Summarize(input, 40);*/
String output = null;
using (StreamReader info = new StreamReader(File.OpenRead(root + "\\info.xml"))) {
XElement infoDoc = XElement.Parse(info.ReadToEnd());
output = new Summarisation().ProcessXML(infoDoc);
}
if (output == null) return null;
/*punem in baza de date rezultatul*/
doc = this._em.AddDocumentOutput(this._doc.DocumentId, "summ",
DocumentManager.StatusOK, output);
/*scriem si in fisier*/
using (Stream stream = File.OpenWrite(root + "\\summ.xml")) {
byte[] buffer = Encoding.UTF8.GetBytes(output);
stream.Write(buffer, 0, buffer.Length);
}
return doc;
}