u实验步骤(4):
FileOption.cs文件中添加代码如下:
//==============================第二部分:类设计============================
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
 
namespace FileOptionApplication
{
    class MyFileOption
    {
        /// <summary>
        /*******************************************************
        **方法 名:WriteTextFile
        **输入参数:filepath:文件路径;
        **          filecontent:写入文件的内容
        **          WriteMethord:写入方法(0:打开并创建文件;1:添加文本;2:新建文本)
        **输出参数:逻辑类型参数
        **返 回 值:bool
        **创建 人:钱哨
        **创建日期:09-7-9
        **描    述:打开存放在某目录下名称为filepath文件,并在该文件中写入filecontent。
        *******************************************************/
        public bool WriteTextFile(string filepath, string filecontent, Int16 WriteMethord)
        {
            bool i = true;
            try
            {
                if (WriteMethord == 0)
                {
              FileStream textfile = File.Open(filepath, FileMode.OpenOrCreate, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(textfile, Encoding.Default);
                    sw.Write(filecontent);
                    i = true;
                    sw.Close();
                    textfile.Close();
                }
                else if (WriteMethord == 1)
                {
                    FileStream textfile = File.Open(filepath, FileMode.Append, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(textfile, Encoding.Default);
                    sw.Write(filecontent);
                    i = true;
                    sw.Close();
                    textfile.Close();
                }
                else if (WriteMethord == 2)
                {
                    FileStream textfile = File.Open(filepath, FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(textfile, Encoding.Default);
                    sw.Write(filecontent);
                    i = true;
                    sw.Close();
                    textfile.Close();
                }
                return i;
            }
            catch
            {
                i = false;
                return i;
            }
        }
        /// <summary>
        /*******************************************************
        **方法 名:DiskFileOption
        **输入参数:SourcePath:源文件路径;
        **           TargetPath:目的文件路径;
        **           OptionMethord:操作类别;0:文件创建;1:文件删除;2:文件复制;3:文件移动
        **输出参数:逻辑类型参数
        **返 回 值:bool
        **创 建 人:钱哨
        **创建日期:09-7-9
        **描    述:对磁盘文件实施基本操作。
        *******************************************************/
        public bool DiskFileOption(string SourcePath, string TargetPath, Int16 OptionMethord)
        {
            bool i = true;
            try
            {
                if (OptionMethord == 0)
                {
                   //文件创建
                    FileStream textfile = File.Create(SourcePath);
                    textfile.Close();
                }
                else if (OptionMethord == 1)
                {
                    //文件删除
                    File.Delete(SourcePath);
                }
                else if (OptionMethord == 2)
                {
                    //文件复制
                    File.Copy(SourcePath, TargetPath, true);
                }
                else if (OptionMethord == 3)
                {
                    //文件移动
                    File.Move(SourcePath,TargetPath);
                }
                return i;
            }
            catch
            {
                i = false;
                return i;
            }
        }
....(未完待续)