27. oktober 2005 - 19:31Der er
2 kommentarer og 1 løsning
TFileStream Read Write?
Hej...
Nu har jeg i et længere stykke tid forsøgt at finde ud af hvordan man benytter streams i delphi... Og indtil nu, har jeg kun fået frustrationer ud af det.
Måske er der en, der kan fortælle f.eks. hvordan jeg skriver og læser en string fra en TFileStream. Og evt. kunne forklare mig hvorfor, præcis de parametre der bliver brugt er benyttet.
I et inbound callcenter, hvor identiteten på den, der ringer ind, skal bekræftes, kan kontrollen nu foregå i telefonkøen. Det understøtter fem centrale KPI'er for callcentre.
Hvad mener du med at læse en string fra en filestream ? Hvis det er en ASCII fil (altså ikke binær), så brug en Tstringlist, det er nemmere.
Vedr. parametre synes jeg det er miget godt forklaret i hjælpen:
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.
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.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.