How to delete file

Just starting out? Need help? Post your questions and find answers here.
bmld76
Posts: 27
Joined: Wed May 24, 2023 5:10 pm

How to delete file

Post by bmld76 »

Hello,

I create a file in #PB_LocalStorage to test a record of a sqlite database. I don't find how to delete this file. The Purebasic command DELETE FILE don't exit in Spiderbasic.

Code: Select all

        *DatabaseBuffer = ExportDatabaseMemory(0)
        If CreateFile(0, FichierBase, @CreateFileCallback(), #PB_LocalStorage)
          WriteData(0, *DatabaseBuffer, 0, MemorySize(*DatabaseBuffer))
          CloseFile(0)
        EndIf
Thank for your help
akee
Posts: 20
Joined: Fri Jun 27, 2014 7:20 pm

Re: How to delete file

Post by akee »

+1
Quin
Posts: 118
Joined: Wed Nov 08, 2023 4:38 pm

Re: How to delete file

Post by Quin »

+1
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How to delete file

Post by Peter »

bmld76 wrote: Sat Oct 21, 2023 3:48 pmI don't find how to delete this file.
try this:

Code: Select all

Procedure DeleteFile(FileName$, Mode=0)
  
  ! LocalForage.removeItem("sbfs_" + v_filename$).then(function() {
  !   // Run this code once the file has been removed.
  Debug "The file was successfully deleted"
  ! }).catch(function(err) {
  !   // This code runs if there were any errors
  !   console.error(err);
  ! });
  
EndProcedure
P.S.: The code only works if at least one file command (e.g. CreateFile()) is present in the code. Only then will the LocalForage library of SpiderBasic be integrated into the code.
Post Reply