Forum > Database

File Locked

(1/2) > >>

C#R#:
Hi,

I have a lot of orginal database files, and select one to see and change with OpenDialog1.
I make copy of original database file to another, to avoid changes on original file (sqlite3)
It's working fine on linux, but on windows no.
DatasetEventos.filename always = 'showing', to get a easy way.
On windows, at first time the copy 'showing' works fine, but if I open another file, the file 'showing' is locked, but I have DatasetEventos.close before copy !!! 
Anybody know why ?

Thanks.



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      Form1.DatasetEventos.close;        if OpenDialog1.execute then begin         path :=  ExtractFileDir(OpenDialog1.FileName) + {$IFDEF WINDOWS} '\' {$ELSE} '/' {$ENDIF}  ;        FileUtil.CopyFile(OpenDialog1.FileName, path + 'showing',[cffOverwriteFile],false);  

Thaddy:
http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Empty_file_names_and_double_path_delimiters

C#R#:
Hi Thaddy, thank you for repply !

The problem is not a name, look:

1) Run the application
2) select a file to open
3) copy the file selected to another, with name 'showing'
4) open and edit 'showing' (sqlite3)  (at this point, the app show a graphic of data)
5) close 'showing'
6) go to 2 <---  at this time, on windows, 'showing' is locked by the OS, and the
next FileUtil.CopyFile will fail, if I try to delete 'showing' while the application is open, I get a error message.
On linux, I have no problems.

Thanks !

lainz:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$IFDEF WINDOWS} '\' {$ELSE} '/' {$ENDIF}
There is 'PathDelim' also..

About the error, it happens very often, the error is that the file gets locked because an application is using it (at least it says windows). There is a program called unlocker that unlocks the file for you, but is not working well under windows 10, at least for me.

Of course you need a solution that does not involve a third party application, the only thing I need to do always this happens is restart the PC and then delete that file or folder.

Check this, files can be deleted on reboot:
https://www.raymond.cc/blog/why-are-you-asked-to-restart-after-install-or-uninstall-software/

lainz:
When you copy the file use another name, so doesn't matter if get's blocked or not is a different file and you will have no problems.

Showing1
Showing2
ShowingN

Navigation

[0] Message Index

[#] Next page

Go to full version