Does a file exist

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 382
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Does a file exist

Post by maxs » Sat Jan 21, 2017 8:14 pm

I've been exporting files to my document folder, like " export image "seats" to file "seats.png" as PNG"

How can I tell if a file exists outside the app? The "exists" function work only with files inside LC.

Also, Is there a way to delete a file in my documents folder?

Max

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1985
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Does a file exist

Post by jmburnod » Sat Jan 21, 2017 8:44 pm

Hi Max,
Yes both we can :D
How can I tell if a file exists outside the app? The "exists" function work only with files inside LC.

Code: Select all

Answer (there is a file MyFilePath)
Also, Is there a way to delete a file in my documents folder?

Code: Select all

put specialfolderpath("documents") & "/" & MyFileName into MyFilePath
delete file MyFilePath
Best regards
Jean-Marc

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 382
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Does a file exist

Post by maxs » Sat Jan 21, 2017 11:41 pm

Thank you,

So simple, and so quick. This really helps.

gagsoft
Posts: 70
Joined: Sat Jun 29, 2013 7:56 pm
Location: Cape Town South Africa

Re: Does a file exist

Post by gagsoft » Wed May 24, 2017 7:48 pm

Hi
I am looking for something similar. I want to delete all files in a specific folder.
My code: This does not work.

Code: Select all

on mouseUp
   put specialFolderPath("documents") & "/" & "psendwip/" & "*.*" into tFilesToWipe
delete file tFilesToWipe
end mouseUp
Any help would be appreciated
Thanks
Peter G

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1985
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Does a file exist

Post by jmburnod » Wed May 24, 2017 9:40 pm

Hi Peter,
To delete all files of a folder you have to get the list of files. You can do it with "the files" after you have defined target folder as default folder
Once you get this list you can use a loop to delete all files.
Something like that:

Code: Select all

on mouseUp
   put specialFolderPath("documents") & "/" & "psendwip" into tFolder --psendwip = the name of  folder target
   set the folder to tFolder--define default folder
   put the files into tAllFiles-- get list files
   repeat for each line tOneFile in tAllFiles --a loop to delete all files
      put tFolder & "/" & tOneFile into tPathFile
      delete file tPathFile
   end repeat
end mouseUp
Best regards
Jean-Marc

gagsoft
Posts: 70
Joined: Sat Jun 29, 2013 7:56 pm
Location: Cape Town South Africa

Re: Does a file exist

Post by gagsoft » Thu May 25, 2017 9:02 am

Hi Jean-Marc
Many thanks :D
Works like a charm.
Really appreciate this.
Best
Peter G

Post Reply

Return to “iOS Deployment”