![]() |
Re: Überprüfen ob Datei verfügbar
To create or open a file and get access to a handle for the file, you simply instantiate a TFileStream. This opens or creates a named file and provides methods to read from or write to it. If the file cannot be opened, TFileStream raises an exception.
constructor Create(const filename: string; Mode: Word); The Mode parameter specifies how the file should be opened when creating the file stream. The Mode parameter consists of an open mode and a share mode or’ed together. The open mode must be one of the following values: Table 1.11 Open modes Value Meaning fmCreate TFileStream a file with the given name. If a file with the given name exists, open the file in write mode. fmOpenRead Open the file for reading only. fmOpenWrite Open the file for writing only. Writing to the file completely replaces the current contents. fmOpenReadWrite Open the file to modify the current contents rather than replace them. The share mode can be one of the following values with the restrictions listed below: Table 1.12 Share modes Value Meaning fmShareCompat Sharing is compatible with the way FCBs are opened. fmShareExclusive Other applications can not open the file for any reason. fmShareDenyWrite Other applications can open the file for reading but not for writing. fmShareDenyRead Other applications can open the file for writing but not for reading. fmShareDenyNone No attempt is made to prevent other applications from reading from or writing to the file. Note that which share mode you can use depends on which open mode you used. The following table shows shared modes that are available for each open mode. Open Mode fmShareCompat fmShareExclusive fmShareDenyWrite fmShareDenyRead fmShareDenyNone fmOpenRead Can’t use Can’t use Available Can’t use Available fmOpenWrite Available Available Can’t use Available Available fmOpenReadWrite Available Available Available Available Available The file open and share mode constants are defined in the SysUtils unit. |
Re: Überprüfen ob Datei verfügbar
Ich stell mich sicher zu blöd an. Denn es will net. Der Compiler meckert:
[Error] Unit1.pas(299): ')' expected but ',' found |
Re: Überprüfen ob Datei verfügbar
da hast du wohl irgendwas vergessen. sollte ungefähr so aussehen
Delphi-Quellcode:
Edit: hatte vergessen "delphicode-tag" zu schließen
var mystream: TStream; //oder TFileStream
begin try mystream := TFilestream.create('c:\meinedatei.txt', fmOpenReadWrite or fmShareExclusive); //lesen schreiben etc finally mystream.free; end; end; |
Re: Überprüfen ob Datei verfügbar
Jo danke...es klappt :)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:14 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz