本文整理汇总了C#中StreamWriter.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriter.ToString方法的具体用法?C# StreamWriter.ToString怎么用?C# StreamWriter.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamWriter
的用法示例。
在下文中一共展示了StreamWriter.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
int iCountTestcases = 0;
chArr = new Char[]{
Char.MinValue
,Char.MaxValue
,'\t'
,' '
,'$'
,'@'
,'#'
,'\0'
,'\v'
,'\''
,'\u3190'
,'\uC3A0'
,'A'
,'5'
,'\uFE70'
,'-'
,';'
,'\u00E6'
};
try
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
iCountTestcases++;
try
{
iCountTestcases++;
sw.Write(null, 0, 0);
iCountErrors++;
printerr( "Error_5787s! Expected exception not thrown, sw=="+sw.ToString());
}
catch (ArgumentNullException)
{
}
sw.Close();
}
catch (Exception exc)
{
iCountErrors++;
printerr( "ERror_91098! Unexpected exception thrown, exc=="+exc.ToString());
}
try
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
iCountTestcases++;
try
{
sw.Write(chArr, -1, 0);
iCountErrors++;
printerr( "Error_298vy! Expected exception not thrown, sw=="+sw.ToString());
}
catch (ArgumentOutOfRangeException)
{
}
sw.Close();
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_98y89! Unexpected exception thrown, exc=="+exc.ToString());
}
try
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
iCountTestcases++;
try
{
sw.Write(chArr, 0, -1);
iCountErrors++;
printerr( "Error_209ux! Expected exception not thrown, sw=="+sw.ToString());
}
catch (ArgumentOutOfRangeException)
{
}
sw.Close();
}
catch (Exception exc)
{
iCountErrors++;
printerr( "Error_298cy! Unexpected exception thrown, exc=="+exc.ToString());
}
try
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
iCountTestcases++;
try
{
sw.Write(chArr, 1, chArr.Length);
iCountErrors++;
printerr( "Error_20deh! Expected exception not thrown, sw=="+sw.ToString());
}
catch (ArgumentException)
//.........这里部分代码省略.........
示例2: Export
private void Export(string FileType, string FileName)
{
try
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
FileStream fs = new FileStream("~/", FileMode.Open);
StreamWriter tw = new StreamWriter(fs);
HtmlTextWriter hw = new HtmlTextWriter(tw);
DutyRecordGridView.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}