Android Question TXT-File exists, but can't be read (no such file)

MTPortal

New Member
Licensed User
Hi folks,

I'm getting crazy here. I'm trying to read a txt-file as a list using a string for the filename, but it won't work.

If I use this code:
B4X:
CurrentList = File.ReadList(File.DirInternal, "Baumliste.txt" )
it works, but if I use:

B4X:
Dim filename As String
  
filename = ListTitel
  
CurrentList = File.ReadList(File.DirInternal, filename & ".txt" )
(where ListTitel is "Baumliste") it doesn't.
Could this line be the problem:
B4X:
ListTitel = File.ReadString(File.DirInternal,"curlist.txt")
What am I doing wrong? Checked the internal folder and the file exists.

Thanks in advance ...
 

MTPortal

New Member
Licensed User
do a log after reading the "filename"...
B4X:
ListTitel = File.ReadString(File.DirInternal,"curlist.txt")
log("ListTitel = "&ListTitel)
to see what you really want to read.... It should be ONLY "Baumliste"... No character more....
I did. Here's the result:

ListTitel = Baumliste
 

MTPortal

New Member
Licensed User
1. Why aren't you reading the files from File.DirAssets directly?
2. I don't see anywhere in your code that you are copying Baumliste.txt to the internal libraries folder.
3. You should initialize any object in sub Process_Globals.
1. Because only a few lists will be "presets" and they have to be editable and users may add their own lists.
2. It's in "DeployPresets" in the "subs"-module.
3. Which object do you mean?
 

haddad

Member
Licensed User
hi
its many day's im bloked to read a line from a file .txt dawnoalded from web-server white many fonction file.listread...textreader

i dont know what's de probleme , the file is dawnoalded whit success i open it with " gestionnaire d'aplication" is ok

that's my code :

Sub JobDone (job As HttpJob)

If job.Success = True Then

Select job.JobName

Case "job1"
Dim outs As OutputStream
outs = File.OpenOutput(File.DirRootExternal&"/fichiermiseajour","prod.csv",False)
File.Copy2(job.GetInputStream,outs)
ProgressDialogHide


Msgbox("le telechargemet de " & job.Tag & " est terminé","info")

outs.Close
p.ReleaseKeepAlive
csvload

Case "job2"

Dim out2 As OutputStream
Dim list As List
out2 = File.OpenOutput(File.DirRootExternal&"/fichiermiseajour","version.txt",False)
File.Copy2(job.GetInputStream,out2)

list = File.ReadList(File.DirRootExternal&"/fichiermiseajour",job.Tag)

For i =0 To list.Size-1

Log(list.Get(i))


Next

Msgbox("le telechargemet de " & job.Tag & " est terminé","info")

out2.Close

' If versionactual < version.SubString(5) Then
'
' Msgbox("nouvelle mise ajour est disponible","info")
'
'
'
' End If
'


End Select

Else

Msgbox("erreur:" & job.ErrorMessage ,"info")

End If

job.Release

End Sub





sorry for my bed english


cordialement
 
Top