Thanks for the multiple USING syntax.
I have applied the syntax to part of a sample I am currently doing for ClickStartXSharp, involving Await methods in 'Stream' classes.
The code is below - it reads one file and creates two more with the read contents :-
Code: Select all
public async method MyStreamReaderWriterTest(cFilePath as string, cNuFile1 as string, cNuFile2 as string) as void
if File.Exists(cFilePath)
begin using local sw1 := StreamWriter{cNuFile1}, ;
sw2 := StreamWriter{cNuFile2} as StreamWriter
begin using local sr := StreamReader{cFilePath} as StreamReader
local cDetails as string
try
local cResult := "" as string
cResult := await sr:ReadToEndAsync()
MessageBox.Show(cResult,"File contents :")
await sw1:WriteAsync(cResult)
await sw2:WriteAsync(cResult)
catch oEX as SystemException
MessageBox.Show(oEX:Message,"my Error buffering :")
end try
end using
end using
else
MessageBox.Show("No such file found on disc ....","my Error file reading :")
endif
return
Is this possible ?
Personally, I think I could make it more readable to help keep Wolfgang happy, but is it allowed, and if so what is the syntax ?
Here is the result :-
Regards,
Phil.