using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
namespace test
{
class Program
{
static void Main(string[] args)
{
#region 一行一行读取
//int counter = 1;
//string line;
//System.IO.StreamReader file = new System.IO.StreamReader(@"F:/WinForm/test/test/test/test.txt");
//while ((line = file.ReadLine()) != null)
//{
// System.Console.WriteLine(line);
// counter++;
//}
//file.Close();
//System.Console.WriteLine("There were {0} lines:", counter);
//System.Console.ReadLine();
#endregion
#region 字符去空格一行一行字符串
// string File_Name = @"F:/WinForm/test/test/test/test.txt";
// if (!File.Exists(File_Name))
// {
// Console.WriteLine("{0} does not exist!", File_Name);
// return;
// }
// ArrayList ar = new ArrayList();
// ar = GetString(File_Name);
// for (int i = 0; i < ar.Count; i++)
// {
// Console.WriteLine(ar[1]);
// string c = ar[1].ToString().Replace(" ", "");//去字符串中的空格
// string b = ar[1].ToString().Trim();//TRIM()只能删除前后空格
// string a = ar[1].ToString().Trim().Substring(8);//取前面8个字符
// int first=ar[1].ToString().IndexOf("<");
// int last=ar[1].ToString().LastIndexOf(">");
// string str2=ar[1].ToString().Substring(first+1,last-first-1);
// Console.WriteLine("{0}",str2);
// Console.WriteLine(c);
// Console.WriteLine(ar[2]);
// Console.ReadLine();
// }
//}
//public static ArrayList GetString(string a)
//{
// ArrayList arr = new ArrayList();
// StreamReader sr = new StreamReader((System.IO.Stream)File.OpenRead(a), System.Text.Encoding.Default);
// try
// {
// while (sr.Peek() != -1)
// {
// arr.Add(sr.ReadLine());
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e.Message);
// }
// return arr;
//}
#endregion
#region
//string str = "A silly sentence used for silly purposes.";
//System.Console.WriteLine("'{0}'", str);
//bool test1 = str.StartsWith("a silly");
//System.Console.WriteLine("starts with 'a silly'? {0}", test1);
//bool test2 = str.StartsWith("a silly", System.StringComparison.OrdinalIgnoreCase);
//System.Console.WriteLine("starts with 'a silly'? {0} (ignoring case)", test2);
//bool test3 = str.EndsWith(".");
//System.Console.WriteLine("ends with '.'? {0}", test3);
//int first = str.IndexOf("silly");
//int last = str.LastIndexOf("silly");
//string str2 = str.Substring(first, last - first);
//System.Console.WriteLine("between two 'silly' words: '{0}'", str2);
//Console.ReadLine();
#endregion
#region
string filename = @"F:/WinForm/test/test/test/test.txt";
if (System.IO.File.Exists(filename))
{
Stream s = new FileStream(@"F:/WinForm/test/test/test/test.txt", FileMode.Open);
StreamReader sr = new StreamReader(s, Encoding.Default);
string str = sr.ReadToEnd().ToString().Trim().Replace(" ", "");
int first = str.IndexOf("<");
int last = str.LastIndexOf(">");
string str1 = str.Substring(first, last - first);
Console.WriteLine(str1);
Console.ReadLine();
sr.Close();
s.Close();
}
#endregion
}
}
}