日期:2014-05-18  浏览次数:20812 次

关于C#进程的问题
我的代码事这样的
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Book
{
  public class Book 
  {
  private string bookID;
  private string bookName;
  private string publish;
  private string author;

  public string BookID {
  get { return bookID; }
  set { bookID = value; }
  }
  public string BookName {
  get { return bookName; }
  set { bookName = value; }
  }
  public string Publish {
  get { return publish; }
  set { publish = value; }
  }
  public string Author {
  get { return author; }
  set { author = value; }
  }
  }

  public class BookMethod
  {
  Book book = new Book();
  public void into1(string a){
  FileStream fs = new FileStream("e:\\aa.txt",FileMode.Create,FileAccess.Write);
  StreamWriter sw = new StreamWriter(fs);
  sw.WriteLine(a);
  sw.Close();
  }
  //输入
  public void into(string a) {
  StreamWriter writer = new StreamWriter("e:\\aa.txt",true);
  writer.WriteLine(a);
  writer.Close();
  }//输出所有
  public void outf() {
  string text;
  FileStream fs1 = new FileStream("e:\\aa.txt",FileMode.Open,FileAccess.Read);
  StreamReader sr = new StreamReader(fs1);
  text=sr.ReadToEnd();
  Console.WriteLine(text);
  sr.Close();
  fs1.Close();
  }
  //根据书号查询  
  public void outf1(string b) {
  FileInfo fi = new FileInfo("e:\\aa.txt");
  StreamReader sr = fi.OpenText();
  string text; do{
  string[] text2=new string[4];
  text = sr.ReadLine();
  //?
  try { 
  text2= text.Split(' ');
  }catch(SystemException e){
  Console.WriteLine(e.Message);
  }
   
  if(text2[0]==b)
  Console.WriteLine(text);
  }while(text!=null);
  sr.Close();
  }
  public string outf2(string b)
  {
  FileInfo fi = new FileInfo("e:\\aa.txt");
  StreamReader sr = fi.OpenText();
  string text;
  string text3;
  do
  {
  string[] text2 = new string[4];
  text = sr.ReadLine();
  //?
  try
  {
  text2 = text.Split(' ');
  }
  catch (SystemException e)
  {
  Console.WriteLine(e.Message);
  }

  if (text2[0] == b)
  {Console.WriteLine(text);
  te