D DataMiser Member Licensed User Mar 6, 2017 #1 I have a text file that was created on the PC in notepad. It contains 100 lines of plain text. I added this file using the files tab in the project. The file gets placed on the device in the files/virtual_assets folder as expected. When I try to read the file into a list using the textreader.readlist I get 11 items I copied the file back to the PC and opened it with notepad and it is nothing like the original. For example the content was a list of sentences n English After the file is moved to the device it looks like the bit below [`vÑ|AÐ)º}IÒ7Ù¦met1$yçkò©=¤ Any idea why this happened and/or what I need to do to include a text file that will be usable on the device. Also I know that b4a uses LF as a terminator but am wondering if having files that have the CRLF in them would be an issue. Would I need to strip the CR from files that were created on the PC under notepad for example.
I have a text file that was created on the PC in notepad. It contains 100 lines of plain text. I added this file using the files tab in the project. The file gets placed on the device in the files/virtual_assets folder as expected. When I try to read the file into a list using the textreader.readlist I get 11 items I copied the file back to the PC and opened it with notepad and it is nothing like the original. For example the content was a list of sentences n English After the file is moved to the device it looks like the bit below [`vÑ|AÐ)º}IÒ7Ù¦met1$yçkò©=¤ Any idea why this happened and/or what I need to do to include a text file that will be usable on the device. Also I know that b4a uses LF as a terminator but am wondering if having files that have the CRLF in them would be an issue. Would I need to strip the CR from files that were created on the PC under notepad for example.
M Mahares Expert Licensed User Longtime User Mar 6, 2017 #2 Use Notepad ++ instead of Notepad. You can download it free. Open file in Notepad ++ and save it in Notepad++, then see what it looks like. Otherwise, post file for members to check it out. Upvote 0
Use Notepad ++ instead of Notepad. You can download it free. Open file in Notepad ++ and save it in Notepad++, then see what it looks like. Otherwise, post file for members to check it out.
D DataMiser Member Licensed User Mar 6, 2017 #3 It is just a simple text file, plain English. If I manually copy the file to the folder on the device it works fine but when I include it under the files tab of the project that seems to be doing something to the file. The file that ends up on the device looks like maybe it is being compressed as it is smaller and contains binary data rather than plain text. Upvote 0
It is just a simple text file, plain English. If I manually copy the file to the folder on the device it works fine but when I include it under the files tab of the project that seems to be doing something to the file. The file that ends up on the device looks like maybe it is being compressed as it is smaller and contains binary data rather than plain text.
P panagiotisden2 Active Member Licensed User Longtime User Mar 6, 2017 #4 try UTF-8 encoding? Upvote 0
D DataMiser Member Licensed User Mar 6, 2017 #5 Same result using UTF-8, Previous was using ANSI I also tried renaming the file to DataFile.Dat but get the same result. I am thinking I am doing something wrong in terms of how I am adding the file. Upvote 0
Same result using UTF-8, Previous was using ANSI I also tried renaming the file to DataFile.Dat but get the same result. I am thinking I am doing something wrong in terms of how I am adding the file.
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2017 #6 Don't use TextReader. Use File.ReadList instead. The result will be the same but it is simpler. DataMiser said: Any idea why this happened and/or what I need to do to include a text file that will be usable on the device. Click to expand... You don't need to do anything special. The file is internally compressed but it doesn't matter. You should use the standard file methods and it will return the file content. Upvote 0
Don't use TextReader. Use File.ReadList instead. The result will be the same but it is simpler. DataMiser said: Any idea why this happened and/or what I need to do to include a text file that will be usable on the device. Click to expand... You don't need to do anything special. The file is internally compressed but it doesn't matter. You should use the standard file methods and it will return the file content.
D DataMiser Member Licensed User Mar 6, 2017 #7 Changed the code to Code: Copy cList.AddAll(File.ReadList(File.DirDefaultExternal &"/Virtual_assets","datafile.dat")) Same result Only seems to work if I manually copy the file from the PC to the device. btw. I have not yet updated to 6.80 if that makes any difference Upvote 0
Changed the code to Code: Copy cList.AddAll(File.ReadList(File.DirDefaultExternal &"/Virtual_assets","datafile.dat")) Same result Only seems to work if I manually copy the file from the PC to the device. btw. I have not yet updated to 6.80 if that makes any difference
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2017 #8 I see. This is not the correct way to access asset files. You should never try to access "virtual_assets" folder directly. Code: Copy clist.AddAll(File.ReadList(File.DirAssets, "datafile.dat")) Upvote 0
I see. This is not the correct way to access asset files. You should never try to access "virtual_assets" folder directly. Code: Copy clist.AddAll(File.ReadList(File.DirAssets, "datafile.dat"))
D DataMiser Member Licensed User Mar 6, 2017 #10 btw I am really liking B4A, very glad I gave it a try. I have even found that some of my VB.Net code works without any changes and other works with minor changes. Of course some is totally incompatible but it is a nice bonus that I can use some of my existing code when converting my Windows Mobile apps written in VB.Net to Android and B4A. Upvote 0
btw I am really liking B4A, very glad I gave it a try. I have even found that some of my VB.Net code works without any changes and other works with minor changes. Of course some is totally incompatible but it is a nice bonus that I can use some of my existing code when converting my Windows Mobile apps written in VB.Net to Android and B4A.
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2017 #11 Great! DataMiser said: I have even found that some of my VB.Net code works without any changes and other works with minor changes. Of course some is totally incompatible but it is a nice bonus that I can use some of my existing code when converting my Windows Mobile apps written in VB.Net to Android and B4A. Click to expand... The next step is to try B4J Upvote 0
Great! DataMiser said: I have even found that some of my VB.Net code works without any changes and other works with minor changes. Of course some is totally incompatible but it is a nice bonus that I can use some of my existing code when converting my Windows Mobile apps written in VB.Net to Android and B4A. Click to expand... The next step is to try B4J
D DataMiser Member Licensed User Mar 6, 2017 #12 I downloaded it a couple of days ago but so far can't pull myself away from B4A Upvote 0
M Mahares Expert Licensed User Longtime User Mar 6, 2017 #13 Erel said: clist.AddAll(File.ReadList(File.DirAssets, "datafile.dat")) Click to expand... Can he just do this: Code: Copy clist = File.ReadList(File.DirAssets, "datafile.dat") I have a feeling you are going to tell me they are the same and I would have wasted a post. Upvote 0
Erel said: clist.AddAll(File.ReadList(File.DirAssets, "datafile.dat")) Click to expand... Can he just do this: Code: Copy clist = File.ReadList(File.DirAssets, "datafile.dat") I have a feeling you are going to tell me they are the same and I would have wasted a post.
Erel B4X founder Staff member Licensed User Longtime User Mar 7, 2017 #14 Yes, assuming that he doesn't want to add the elements to an existing list. Upvote 0