I can not delete files on windows
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
I can not delete files on windows
I create a folder and copy a file to that folder, works fine.
I then try to delete the file and it works as it should on Mac but when I try this on windows, I get the result "Can not delete that file."
How is it that, and what can I do?
My code (the short version):
set the defaultFolder to specialFolderPath ("Desktop")
put the defaultFolder & "/" into tFolder
put "Pro-cell images" after tFolder
set the cTempFolder of me to tFolder
set the defaultFolder to specialFolderPath ("temporary")
put the defaultFolder & "/" into tFolder
put "Cell images" after tFolder
set the cImageFolder of me to tFolder
#######Here I copy a file into the folder Pro-cell images###########
set the defaultfolder to the cImageFolder of me
put the defaultFolder into tFolder
put url("binfile:" & the cTempFolder of me & "/" & theImage ) into url ("binfile:" & tFolder & "/" & theImage )
delete file (the cTempFolder of me & "/" & theImage)
I'm developing on Mac but unfortunately, 90% of my users have PCs, so this does not work is a big problem for me right now.
/// Peter
I then try to delete the file and it works as it should on Mac but when I try this on windows, I get the result "Can not delete that file."
How is it that, and what can I do?
My code (the short version):
set the defaultFolder to specialFolderPath ("Desktop")
put the defaultFolder & "/" into tFolder
put "Pro-cell images" after tFolder
set the cTempFolder of me to tFolder
set the defaultFolder to specialFolderPath ("temporary")
put the defaultFolder & "/" into tFolder
put "Cell images" after tFolder
set the cImageFolder of me to tFolder
#######Here I copy a file into the folder Pro-cell images###########
set the defaultfolder to the cImageFolder of me
put the defaultFolder into tFolder
put url("binfile:" & the cTempFolder of me & "/" & theImage ) into url ("binfile:" & tFolder & "/" & theImage )
delete file (the cTempFolder of me & "/" & theImage)
I'm developing on Mac but unfortunately, 90% of my users have PCs, so this does not work is a big problem for me right now.
/// Peter
/*Whats all the fuss with c# ?*/
Re: I can not delete files on windows
Don't use spaces with names for files and folders. I suggest "Pro-cell_images" and "Cell_images".
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
Re: I can not delete files on windows
MaxV,
I can see your point, unfortunately, it does not help the fact that the file can't be deleted.
Since it is possible to copy to the folder, it is obviously found. And the file name is what it is, I don't understand why this should be a problem when it works perfectly on Mac.
PS. I changed the names so now there are no spaces
///Peter
I can see your point, unfortunately, it does not help the fact that the file can't be deleted.
Since it is possible to copy to the folder, it is obviously found. And the file name is what it is, I don't understand why this should be a problem when it works perfectly on Mac.
PS. I changed the names so now there are no spaces
///Peter
/*Whats all the fuss with c# ?*/
Re: I can not delete files on windows
Which version(s) of Lc and Windows?
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
Re: I can not delete files on windows
LC 9.0.0 (dp9) and widows 10.
/*Whats all the fuss with c# ?*/
Re: I can not delete files on windows
Well, that leaves me out, I have neither to test it on
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: I can not delete files on windows
It could be a permissions problem. Does it work if you change the folder location to the documents folder?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
Re: I can not delete files on windows
No, It makes no difference.
I have also tried to turn off the UAC to see if that was the problem.
I have also tried to turn off the UAC to see if that was the problem.
/*Whats all the fuss with c# ?*/
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: I can not delete files on windows
Do you see anything if you check for an error message:
Code: Select all
delete file (the cTempFolder of me & "/" & theImage)
answer the result && the syserror
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: I can not delete files on windows
Hi,
I assume you have a minor mistake somewhere in your code; carefully testing "the result" and using the debugger should uncover it quite easily.
To be sure it isn't a LC bug I wrote this short button handler - it creates a file in ./temp, copies it to ./docs, then deletes both of those again.
Works flawlessly in Win 10 pro64 (high AC control) & LC 6.7.10.
You may try it to find out if your Win versions/ LC version behaves differently:
Have fun!
I assume you have a minor mistake somewhere in your code; carefully testing "the result" and using the debugger should uncover it quite easily.
To be sure it isn't a LC bug I wrote this short button handler - it creates a file in ./temp, copies it to ./docs, then deletes both of those again.
Works flawlessly in Win 10 pro64 (high AC control) & LC 6.7.10.
You may try it to find out if your Win versions/ LC version behaves differently:
Code: Select all
on mouseUp
put (specialfolderpath("temporary") & "/") into myTempFolder
put (specialfolderpath("documents") & "/") into myDocFolder
put "_XTest.txt" into myFile
put the long date && the long time into myData
put myData into URL ("binfile:" & myTempFolder & myFile)
-- result check here:
put the result into myVar
breakpoint
-- => "XTest.txt" is now in "C:\Users\myName\AppData\Local\Temp"
put URL ("binfile:" & myTempFolder & myFile) into URL ("binfile:" & myDocFolder & myFile)
-- result check here:
put the result into myVar
breakpoint
-- => "XTest.txt" is now in "D:\Users\myName\Documents\" also
delete file (myTempFolder & myFile)
-- result check here:
put the result into myVar
breakpoint
-- => "C:\Users\myName\AppData\Local\Temp\_XTest.txt" got deleted
delete file (myDocFolder & myFile)
-- result check here:
put the result into myVar
breakpoint
-- => all instances of "_XTest.txt" are cleared now
end mouseUp
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
-
- Posts: 136
- Joined: Fri Oct 14, 2011 6:53 am
Re: I can not delete files on windows
Now it works to delete the file!
The file was still in use so I had to close it before I could remove it.
Now I have another problem.
When I set the "fileName" of my image, I get "could not open image".
There is nothing wrong with the pathway, this seems to be a similar issue to the previous problem, except that it can not be resolved by closing the file or folder.
if I copy the pathway and then set the property inspector for the image to it, nothing happens. This applies to all images that I somehow handle in the application.
For example, if I set the pathway in the above way to a desktop image before I use it in the application, it works, but after the program has copied it, it will not work.
And this is still just a Windows issue, Why do not everyone use a Mac.
Suggestions, anyone?
The file was still in use so I had to close it before I could remove it.
Now I have another problem.
When I set the "fileName" of my image, I get "could not open image".
There is nothing wrong with the pathway, this seems to be a similar issue to the previous problem, except that it can not be resolved by closing the file or folder.
if I copy the pathway and then set the property inspector for the image to it, nothing happens. This applies to all images that I somehow handle in the application.
For example, if I set the pathway in the above way to a desktop image before I use it in the application, it works, but after the program has copied it, it will not work.
And this is still just a Windows issue, Why do not everyone use a Mac.
Suggestions, anyone?
/*Whats all the fuss with c# ?*/
Re: I can not delete files on windows
Hi,
maybe I misunderstand, but this works flawlessly here:
It switches between the picts, copies them (overwrites if neccessary), shows the new ones, no problems at all.
Have fun!
maybe I misunderstand, but this works flawlessly here:
Code: Select all
on mouseUp
-- you need an image area named "test_img" besides this btn!
put specialFolderPath("Desktop") & "/Saved Pictures/" into myPath
put specialFolderPath("Desktop") & "/Test_Picts/" into myTestPath
put "P8010001.JPG" into pict1
put "P8010002.JPG" into pict2
if (pict1) is in the fileName of img "test_img" then
set the fileName of img "test_img" to (myPath & pict2)
answer "This the original pict from " & CR & (myPath & pict2) \
with "Cancel" and "Copy it!"
if it is "Cancel" then exit mouseUp
set the fileName of img "test_img" to empty
put URL ("binfile:" & myPath & pict2) into URL ("binfile:" & myTestPath & pict2)
set the fileName of img "test_img" to (myTestPath & pict2)
answer "This the freshly copied pict from " & CR & (myTestPath & pict2)
else
set the fileName of img "test_img" to (myPath & pict1)
answer "This the original pict from " & CR & (myPath & pict1) \
with "Cancel" and "Copy it!"
if it is "Cancel" then exit mouseUp
set the fileName of img "test_img" to empty
put URL ("binfile:" & myPath & pict1) into URL ("binfile:" & myTestPath & pict1)
set the fileName of img "test_img" to (myTestPath & pict1)
answer "This the freshly copied pict from " & CR & (myTestPath & pict1)
end if
end mouseUp
Quite sure this is not a Windows issue. You might want to check your code again.And this is still just a Windows issue,
There's still a "rest of us", capable of "thinking different", that doesn't like to have a "big brother" in Cupertino to tell us how beautiful life is in an overprized iJail ;-)))Why do not everyone use a Mac.
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!