1. deleting files

delete_file(fileName) does not remove a file.. return 0, not 1 the path, is fine.. used chdir(XXX)to set it the file does exist as does the path.. the file was created using copy_file(x,y) Using win7, eu ver 4.0.3, Win32Lib

new topic     » topic index » view message » categorize

2. Re: deleting files

Send us some code with the euphoria statements in it...

new topic     » goto parent     » topic index » view message » categorize

3. Re: deleting files

All puts(1........) supply expected info, except for the one commented

 
procedure delete_Rel_records() 
	sequence FileName 
puts(1,to_string(personKey) & CrLf) 
	db_select_table("birth") x = db_find_key(personKey) if x > 0 then puts(1,"birth " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("death") x = db_find_key(personKey) if x > 0 then puts(1,"death " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("parents") x = db_find_key(personKey) if x > 0 then puts(1,"parents " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("spouse") x = db_find_key(personKey) if x > 0 then puts(1,"spouse " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("marriages") x = db_find_key(personKey) if x > 0 then puts(1,"marriages " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("relative") x = db_find_key(personKey) if x > 0 then puts(1,"relative " & to_string(x) & CrLf) end if --db_delete_record(x) end if	 
	db_select_table("citation") x = db_find_key(personKey) if x > 0 then puts(1,"citations " & to_string(x) & CrLf) end if --db_delete_record(x) end if 
	db_select_table("photographs") x = db_find_key(personKey)  
	if x > 0 then puts(1,"photographs " & to_string(x) & "  ")  
		 
		FileName = db_record_data(x)  
		puts(1,to_string(length(FileName)) ) 
		if length(FileName)>2 then 
			puts(1,to_string(FileName) & "  ") 
			puts(1,pathToPhoto & surName & "\\" & FileName & CrLf)  
			if chdir(pathToPhoto & surName & "\\")=1 then 
				puts(1,"path is " & curdir() ) --pathToPhoto & surName & CrLf) 
				if delete_file(FileName )=1 then 
-- this puts(1,....) does not show up....... 
					puts(1,"deleted " & FileName & CrLf) 
				end if 
-- will leave until delete works properly	 
				--db_delete_record(x)  
			end if 
		end if 
	end if 
	 
end procedure 
 
new topic     » goto parent     » topic index » view message » categorize

4. Re: deleting files

The example of chdir in the user guide section 8.5.2.15 does not have a final backslash. Try removing it from your code.
What is the result of

?current_dir() 

after the chdir? It is a long time since I used chdir so this may be red herring.

Arthur

new topic     » goto parent     » topic index » view message » categorize

5. Re: deleting files

The output of ? current_dir will not convert using to_string.. however, using puts(1,to_string(current_dir())) produces the correct path... same as curdir()...omitting the back slash made no diff

Thanks for your reply..

Z

new topic     » goto parent     » topic index » view message » categorize

6. Re: deleting files

The problem seems to be long file names...

How can I use long file names?

new topic     » goto parent     » topic index » view message » categorize

7. Re: deleting files

buzzo said...

The problem seems to be long file names...

How can I use long file names?

Be more specific please.

Why do you think the problem is "long file names".

What is the content of FileName at the time of calling delete_file()?

new topic     » goto parent     » topic index » view message » categorize

8. Re: deleting files

when I call delete_file(FileName) when the name is "gena-1-8-14.jpg" the file is not deleted... when I call content = dir(current_dir()), that file is "listed" as with both forms of the file name: gena-1-8-14.jpg and GENA-1~1.JPG

new topic     » goto parent     » topic index » view message » categorize

9. Re: deleting files

buzzo said...

when I call delete_file(FileName) when the name is "gena-1-8-14.jpg" the file is not deleted... when I call content = dir(current_dir()), that file is "listed" as with both forms of the file name: gena-1-8-14.jpg and GENA-1~1.JPG

Still not enough info.

What happens when you call delete_file() with the 'short name'?

new topic     » goto parent     » topic index » view message » categorize

10. Re: deleting files

Same result..

any way the send a screen shot of the outputs of the puts's?

new topic     » goto parent     » topic index » view message » categorize

11. Re: deleting files

buzzo said...

Same result..

Have you tried not changing directories but doing this instead ...

delete_file(pathToPhoto & surName & "\\" & FileName) 
new topic     » goto parent     » topic index » view message » categorize

12. Re: deleting files

Same result... Thanks...

new topic     » goto parent     » topic index » view message » categorize

13. Re: deleting files

buzzo said...

Same result... Thanks...

Ok ... let's clear up some assumptions next.

  • Does the file actually exist?
  • Has the file actually been deleted but just not getting reported as such?
  • Can you delete the file manually, via the console?
  • Is the file open (by this application or anything else) at the time the delete_file() is being called?
  • Can you display/read the contents of the file?

As for screenshots, you should be able to just do some cut&paste from the console window.

new topic     » goto parent     » topic index » view message » categorize

14. Re: deleting files

My usual approach to things like this is:

1. make sure I can delete the file manually - including while your program is running - maybe it's in use.

2. hard-code the file name and path in the delete_file() call, so you know it is correct, i.e. not being mangled in some way, perhaps excess or missing slashes, etc. IOW, pass delete_file() a plain old string and see what happens.

3. if the hard-coded file is deleted, then obviously previous code which builds the file/path is buggy. Add display() at each step and work your way backward until you find the place it goes wrong.

BTW: what's with the puts(1,to_string(FileName) & " ") ? Does the filename look different if you just use puts(1,FileName & " ")

new topic     » goto parent     » topic index » view message » categorize

15. Re: deleting files

DerekParnell said...
buzzo said...

Same result... Thanks...

Ok ... let's clear up some assumptions next.

  • Does the file actually exist? ''''''''''' yes
  • Has the file actually been deleted but just not getting reported as such? no
  • Can you delete the file manually, via the console? '''''''''' can not ... the file is open... this is the most likely the problem.. will study GdiPlus ..
  • Is the file open (by this application or anything else) at the time the delete_file() is being called? file is loaded and displayed using GdiPlus code
  • Can you display/read the contents of the file? yes

As for screenshots, you should be able to just do some cut&paste from the console window.

new topic     » goto parent     » topic index » view message » categorize

16. Re: deleting files

The matter is resolved... this instruction "closed" the file: status=GdipDisposeImage(pImage) and was placed in my code immediately before: GdipUninitialize()

Thanks for all of your help..

Buzzo

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu