Is there any easy way for us to check if for example, FileA.txt exist, and if it doesn't then use FileB.txt?
I have been looking through the FileSystem and File reference in the help file but I don't seem to find anything relevant. I probably am not looking hard enough though.
Syntax
Result.q = FileSize(Filename$)
Description
Returns the size of the specified file.
Special 'Result' values:
-1: File not found.
-2: File is a directory.
Supported OS
All
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
If you want to use ReadFile(), no need to check it before, it's double check. Also, ALWAYS check the return of ReadFile, it could exists but be locked by an application.
Michael Vogel wrote:Depending if the first readable file should be opened or the first existent should be tried to open there are some variants possible ...
With these functions you can not use #PB_Any, because you would need the result of ReadFile() to Close the opened file.
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Michael Vogel wrote:Depending if the first readable file should be opened or the first existent should be tried to open there are some variants possible ...
With these functions you can not use #PB_Any, because you would need the result of ReadFile() to Close the opened file.
Procedure.l OpenFirstFile(n,a.s,b.s="")
Protected Result
Result=ReadFile(n,a)
If Result
ProcedureReturn Result
Else
Result=ReadFile(n,b)
EndIf
ProcedureReturn Result
EndProcedure
ReadFile() does the trick! I needed someway of checking if one of two files existed, if one did it would set the appropriate file path. Thank you guys for all of the help!
If FileSize("C:\some_file.txt") <> -1 And FileSize("C:\some_file.txt") <> -2
MessageRequester("Information", "Path set", #PB_MessageRequester_Ok)
;set path here
Else
MessageRequester("Information", "file not found", #PB_MessageRequester_Ok)
; file does not exist
EndIf
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.