Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 5 Jahren, 3 Monaten
Letzter Beitrag:
vor 5 Jahren, 3 Monaten
Beteiligte Autoren:
Ola, Piet van Zanten, ICI

[WD16] How to create and re-open TempFiles?

Startbeitrag von Ola am 14.05.2013 07:27

Hi All

I am trying to save some program settings using a TempFile while calling another WD-program and then read that tempfile when coming back to the original program.

The creation seems to go right with a command like:

iFileId is int = fOpenTempFile(foWithoutDeletion, "VRM", "LocalDat")


This creates a file named like "VRM2B85.tmp" where "2B85" is the unique part generated by WD,

I monitored the program transfer process using a file manager and I can see that a tempfile really is created in the specified sub-directory and that the data is all there.

But I cannot read the same file when coming back to the same program:

sFileName is string = fTempFile("VRM", "LocalDat")


This does not find the last created tempfile, but it does return a correct looking tempfile name, but with a unique part that does not exist on disk. So when I try to open that file with fOpen:

iFileId is int = fOpen(sFileName,foRead)

I get an error "File not found".

What should I do to get the correct filename?
I was first thinking of reading all the filenames in the specified directory to a list and then finding the last VRM file from the list, but that seems a little bit like shooting a fly with an 88 mm cannon.

Any hints/guidelines/code snippets will be appreciated

br
Ola

Antworten:

Hi Ola
Maybe to try with fdir() to list all .tmp files in correspond directory and than
perform action.

von ICI - am 14.05.2013 07:51
Hi Ola,

fTempfile always creates a new unique file name, so you need to use the previously created sFileName variable.

Regards,
Piet

von Piet van Zanten - am 14.05.2013 08:16
Hi ICI & Piet

Thanks for the hints.

ICI, fDir seems to give only the filename, but to find the latest one, I would also need to get the file's timestamp.

Piet, I came to the same conclusion, so I "fixed" the problem by using a fixed filename and re-create the same filename whenever needed. This way it works without hickups.

But this makes me wonder the purpose of WD's tempfile system? Obviously it is not very useable as such.

Br
Ola

von Ola - am 14.05.2013 12:32
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.