P postasat Active Member Licensed User Longtime User May 28, 2018 #1 Hi, I need to use in my app a folder path located on Usb stick. Usually, for internal file, I use dialogs library and ShowOnlyFolders to choose the correct folder. Is the usb main path always the same if I connect different stick ? How can I open a filedialog with filepath always set to usb "main folder" ? Is it possible ? I need to write text file data to specific usb folder (textwriter) folder created if needed, and reload the same text data file from the same usb folder, later. Thank you.
Hi, I need to use in my app a folder path located on Usb stick. Usually, for internal file, I use dialogs library and ShowOnlyFolders to choose the correct folder. Is the usb main path always the same if I connect different stick ? How can I open a filedialog with filepath always set to usb "main folder" ? Is it possible ? I need to write text file data to specific usb folder (textwriter) folder created if needed, and reload the same text data file from the same usb folder, later. Thank you.
DonManfred Expert Licensed User Longtime User May 29, 2018 #2 https://www.b4x.com/android/forum/threads/externalstorage-access-sd-cards-and-usb-sticks.90238/ Upvote 0
P postasat Active Member Licensed User Longtime User May 29, 2018 #3 Hi DonManfred, the code I was using for internal text file was this: Code: Copy 'open file data TR1.Initialize(File.OpenInput(foldertoload, filetoload)) 'read data data1 = TR1.ReadLine data2 = TR1.ReadLine data3 = TR1.ReadLine data4 = TR1.ReadLine data5 = TR1.ReadLine listafile = TR1.ReadList TR1.Close How can I modify it to use with externalstorageclass ? Thank you. Upvote 0
Hi DonManfred, the code I was using for internal text file was this: Code: Copy 'open file data TR1.Initialize(File.OpenInput(foldertoload, filetoload)) 'read data data1 = TR1.ReadLine data2 = TR1.ReadLine data3 = TR1.ReadLine data4 = TR1.ReadLine data5 = TR1.ReadLine listafile = TR1.ReadList TR1.Close How can I modify it to use with externalstorageclass ? Thank you.
Erel B4X founder Staff member Licensed User Longtime User May 29, 2018 #4 Accessing the USB storage is a bit more complicated. Start with running the example and being able to access the USB storage. The next step is to call FindFile to get an ExternalFile that points to the relevant file, and call OpenInputStream to open the stream. From that point the code is identical to your code. Upvote 0
Accessing the USB storage is a bit more complicated. Start with running the example and being able to access the USB storage. The next step is to call FindFile to get an ExternalFile that points to the relevant file, and call OpenInputStream to open the stream. From that point the code is identical to your code.
P postasat Active Member Licensed User Longtime User May 30, 2018 #5 Thank you, I did it ! Code: Copy 'open external file USB Storage.OpenInputStream(Storage.FindFile(GetCurrentFolder,filelist)) 'read file TR1.Initialize(File.OpenInput(foldertoload, filelist)) Upvote 0
Thank you, I did it ! Code: Copy 'open external file USB Storage.OpenInputStream(Storage.FindFile(GetCurrentFolder,filelist)) 'read file TR1.Initialize(File.OpenInput(foldertoload, filelist))