如何对*.txt(文本文件)进行操作!!!
如:创建,删除,修改,读取其中某一行或者某一列,等等等等
关于其的所有操作函数!!!!谢谢老大们

解决方案 »

  1.   

    var
      F: File of char;
      a: Char;
    begin
      AssignFile(F,'C:\aa.txt');  //文件名你自己修改
      Rewrite(F);  //进行写操作,读操作用Reset(F);
      WriteLn(F,'你的字符'); //写入一行 读入一行用Readln(F); 读入一个字符用read(f,a);
      closeFile(F);
    end;
      

  2.   

    TstringList
    or
    AssignFile / Reset / Readln / Writeln / closefile
      

  3.   

    嘿嘿function
    Description
    Append Opens an existing text file for appending.
    AssignFile Assigns the name of an external file to a file variable.
    BlockRead Reads one or more records from an untyped file.
    BlockWrite Writes one or more records into an untyped file.
    ChDir Changes the current directory.
    CloseFile Closes an open file.
    Eof Returns the end-of-file status of a file.
    Eoln Returns the end-of-line status of a text file.
    Erase Erases an external file.
    FilePos Returns the current file position of a typed or untyped file.
    FileSize Returns the current size of a file; not used for text files.
    Flush Flushes the buffer of an output text file.
    GetDir Returns the current directory of a specified drive.
    IOResult Returns an integer value that is the status of the last I/O function performed.
    MkDir Creates a subdirectory.
    Read Reads one or more values from a file into one or more variables.
    Readln Does what Read does and then skips to beginning of next line in the text file.
    Rename Renames an external file.
    Reset Opens an existing file.
    Rewrite Creates and opens a new file.
    RmDir Removes an empty subdirectory.
    Seek Moves the current position of a typed or untyped file to a specified component. Not used with text files.
    SeekEof Returns the end-of-file status of a text file.
    SeekEoln Returns the end-of-line status of a text file.
    SetTextBuf Assigns an I/O buffer to a text file.
    Truncate Truncates a typed or untyped file at the current file position.
    Write Writes one or more values to a file.
    Writeln Does the same as Write, and then writes an end-of-line er to the text file.
    **********************************************
    *等我有钱了,我就站在天安门广场挨个给大家发钱*
    **********************************************
      

  4.   

    通过TextFile 类型说明符可以用来声明ASCII 字符的文件,也就是通常所说的“纯文本
    文件”。
    利用文本文件保存数据的优点是:利用常见的文字编辑器就可以浏览其中的内容。在后
    面常用函数的介绍中,如果具体的函数对于上述三类文件有不同的用法时,将做必要的说明。
    同时,通过这些说明,读者可以领会三种文件类型的不同。
    本节讲述使用内建于Object Pascal运行时库中的过程和函数处理文本文件的方法。在对
    文本文z件进行任何处理之前,首先要打开此文本文件。声明变量:
    var
    MyTextFile:Textfile;
    通过此变量可以来引用一个文本文件。
    打开一个文件需要两步:首先是AssignFile() ,它可以将文件变量与一个文件关联起来。
    例如:
    AssignFile(MyTextFile,’MyTextFile.txt’);
    这时,可以进行第二步:打开文件。有三种方式可以打开文件:使用Rewrite 过程创建
    并打开文件;对于一个已存在的文件,此操作将使文件被覆盖;使用Reset 过程只读地打开
    一个文件;使用Append 过程可以向已存在的文件追加文本。注意Reset 将以可读写方式打开
    类型文件和无类型文件。
    134 第6 章文件管理
    可以使用CloseFile来关闭一个已打开的文件。下面我们来看几个例子。
    下面的程序将以只读方式打开一个文件:
    var
    MyTextFile:Textfile;
    begin
    assignfile(MyTextfile,’MyTextFile.txt’);
    reset(MyTextFile);
    try
    {操作文件}
    finally
    CloseFile(MyTextFile);
    end;
    end;
    下面的程序将创建一个新的文件:
    var
    MyTextFile:Textfile;
    begin
    assignfile(MyTextfile,’MyTextFile.txt’);
    rewrite(MyTextFile);
    try
    {操作文件}
    finally
    CloseFile(MyTextFile);
    end;
    end;
    下面的程序将向一个已存在的文件追加新的文本:
    var
    MyTextFile:Textfile;
    begin
    assignfile(MyTextfile,’MyTextFile.txt’);
    append(MyTextFile);
    try
    {操作文件}
    finally
    CloseFile(MyTextFile);
    end;
    end;