FERNANDO SILVEIRA Active Member Licensed User Apr 27, 2018 #1 Hello guys, I have the following code: B4X: bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True) What happen if the file is missing? I'd like to test file existance and if the image is not there, load a default image instead. Same doubt (file not found) reading text from a file. Regards, Fernando
Hello guys, I have the following code: B4X: bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True) What happen if the file is missing? I'd like to test file existance and if the image is not there, load a default image instead. Same doubt (file not found) reading text from a file. Regards, Fernando
Claudio Oliveira Active Member Licensed User Longtime User Apr 27, 2018 #2 Just check if file exists before trying to access it. B4X: If File.Exists(File.DirAssets, wWordOK & ".jpg") then bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True) End if Upvote 0
Just check if file exists before trying to access it. B4X: If File.Exists(File.DirAssets, wWordOK & ".jpg") then bg = LoadBitmapResize(File.DirAssets, wWordOK & ".jpg", ImageView1.Width, ImageView1.Height, True) End if
FERNANDO SILVEIRA Active Member Licensed User Apr 27, 2018 #3 Thanx Claudio, That's exactly what I was looking for. Upvote 0
KMatle Expert Licensed User Longtime User Apr 27, 2018 #4 FERNANDO SILVEIRA said: Thanx Claudio, That's exactly what I was looking for. Click to expand... If you type "File." you'll see all methods the File object has. Upvote 0
FERNANDO SILVEIRA said: Thanx Claudio, That's exactly what I was looking for. Click to expand... If you type "File." you'll see all methods the File object has.
MaFu Well-Known Member Licensed User Longtime User Apr 27, 2018 #5 But why check DirAssets? It's filled at compile time, therefore you should know which files it contains. Upvote 0
But why check DirAssets? It's filled at compile time, therefore you should know which files it contains.
Claudio Oliveira Active Member Licensed User Longtime User Apr 27, 2018 #6 MaFu said: But why check DirAssets? It's filled at compile time, therefore you should know which files it contains. Click to expand... I guess @FERNANDO SILVEIRA's point here is: how to avoid an error for trying to access a missing file. Not necessarily in assets folder... Upvote 0
MaFu said: But why check DirAssets? It's filled at compile time, therefore you should know which files it contains. Click to expand... I guess @FERNANDO SILVEIRA's point here is: how to avoid an error for trying to access a missing file. Not necessarily in assets folder...