From: "Earl F. Glynn" Newsgroups: borland.public.delphi.ide References: <3ac1e11c$1_2@dnews> <3ac1e677_2@dnews> Subject: Re: AssignFile Date: Wed, 28 Mar 2001 09:09:52 -0600 Lines: 54 Organization: efg's Computer Lab X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 12.75.142.148 Message-ID: <3ac1ffbf_1@dnews> X-Trace: 28 Mar 2001 07:14:07 -0800, 12.75.142.148 Path: dnews!12.75.142.148 Xref: dnews borland.public.delphi.ide:46320 "Gert Kello" wrote in message news:3ac1e677_2@dnews... > > I'm trying to use the AssignFile procedure to write to an external >> text file. > Try to use TFileStream. Streams are much more powerful, and they are > more natural in Delphi. While TFileStreams are the contemporary way to do this, AssignFile should still work. This works fine on my network. Do you have some sort of network permission issue? procedure TForm1.ButtonWriteClick(Sender: TObject); VAR LogFile: TextFile; begin AssignFile(LogFile, '\\earlg2\c\temp\Sample.Txt'); Rewrite(LogFile); WriteLn(LogFile, 'Line one'); WriteLn(LogFile, 'Line two'); Closefile(LogFile) end; procedure TForm1.ButtonRead1Click(Sender: TObject); VAR LogFile: TextFile; s : STRING; begin AssignFile(LogFile, '\\earlg2\c\temp\Sample.Txt'); Reset(LogFile); ReadLn(LogFile, s); Memo1.Lines.Add(s); ReadLn(LogFile, s); Memo1.Lines.Add(s); Closefile(LogFile) end; For other File I/O examples, see: http://homepages.borland.com/efg2lab/Library/Delphi/IO/FileIO.htm For FileStream I/O examples, see: http://homepages.borland.com/efg2lab/Library/Delphi/IO/StreamIO.htm -- efg efg2@efg2.com Earl F. Glynn, Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab Mirror: http://homepages.borland.com/efg2lab/Default.htm