Questions tagged [filelock]

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

File locks are locks held by an application, preventing interference from other processes. Locks may be advisory (may be ignored by others), or mandatory, enforced by the operating system, depending on implementation.

190 questions
4
votes
2 answers

How wait and get lock on file

I want wait till other program releases lock on particular file, then I want to proceed to open that unlocked file. I came across many solutions, but none are useful, here is my code - File file = new File("c:\\somelockedfile.txt"); FileChannel…
nullptr
  • 3,320
  • 7
  • 35
  • 68
4
votes
6 answers

Avoid crashing when file is locked?

Resolution from comments: Application crash was caused by another issue I am reading/writting to a file from 2 different applications, when the file is being read or written to, it will always be locked by app A or B and they both make use of…
Prix
  • 19,417
  • 15
  • 73
  • 132
4
votes
2 answers

How to check FileLock without truncating file?

I recently added filelocks to my downloader asynctask: FileOutputStream file = new FileOutputStream(_outFile); file.getChannel().lock(); and after download completes, file.close() to release lock. From a called BroadcastReceiver (different thread),…
NoBugs
  • 9,310
  • 13
  • 80
  • 146
4
votes
2 answers

How to prevent file from being overridden when reading and processing it with Java?

I'd need to read and process somewhat large file with Java and I'd like to know, if there is some sensible way to protect the file that it wouldn't be overwritten by other processes while I'm reading & processing it? That is, some way to make it…
Touko
  • 11,359
  • 16
  • 75
  • 105
4
votes
6 answers

Unable to lock files on Linux using java.nio.channels.FileLock

I was creating an application in Java for which I want only one instance running. For this purpose I created a file and got a lock while my application is running. I have following code which works on Windows, but failed on Linux: once I acquire a…
kaysush
  • 4,797
  • 3
  • 27
  • 47
4
votes
3 answers

Is there a way to delete an output file in a post-build event

I'm trying to run a post-build batch file on a .NET build that encrypts an output file, deletes the original and then renames the encrypted version to the original output filename. i.e.: Build A, then in post-build: Encrypt A->B, DEL /F A, RENAME B…
4
votes
2 answers

NUnit won't release lock on custom class library dll ... Unable to compile class library after running NUnit

I wrote a custom class library for NUnit unit tests. It created a dll file containing my .NET IL code in the {project root}\bin\Debug\ folder. Running NUnit unit tests in this class library works fine, but if I try to compile my class library…
JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
3
votes
1 answer

Apache Camel GenericFileOperationFailedException: 'Cannot rename file' locks exchange

We have an integration system based on Camel v2.16.1 that runs on a Jboss v6 Linux platform. There are multiple interfaces running simultaneously each with a different polling rate. We are intermittently experiencing 'Cannot rename file' issue with…
3
votes
4 answers

How to lock file in Ubuntu server when editing

It's my first time developing a project with other developers (only two, right now). Our idea is to edit the files right from the server, using a FTP/SFTP software such as FileZilla. We want that any file opened for editing become blocked, so the…
Rodrigo
  • 4,706
  • 6
  • 51
  • 94
3
votes
2 answers

File locks when using file.move in c#...how can I stop or fix this

Code: String tempFile = Path.GetTempFileName(), read = ""; TextReader pending = new StreamReader("c:\\pending.txt"); TextWriter temp = new StreamWriter(tempFile); read = pending.ReadLine(); while ((read =…
Mtlca401
  • 31
  • 1
  • 2
3
votes
1 answer

Release a file lock that send-mailmessage leaves on error

I'm using the Send-MailMessage cmdlet to send a copy of a log file. However, I'd like to add a line to the log file with the status of the Send. Code: $To = "toaddress@email.com" $Subject = "Test Email Attachment" $From =…
M Jeremy Carter
  • 433
  • 4
  • 9
3
votes
4 answers

How to use FileLock on android?

I think that we are able to lock files for exclusive access as i saw this link: http://developer.android.com/reference/java/nio/channels/FileLock.html I want to create a save/load a file both in a background process (service) and the real foreground…
frankish
  • 6,738
  • 9
  • 49
  • 100
3
votes
3 answers

File locking in Linux using C program

I want to create one file from c program and i want use bit long time in my c binary. But i want create file in such way that until my c program finish processing file created and unlock it nobody(may using vim or any other editor) can able to open…
user1837947
  • 31
  • 1
  • 1
  • 2
2
votes
1 answer

Java FileLock: How to Load Dynamic Library From Locked File?

I have an applet that retrieves a byte array from a backend server. This byte array contains a dynamic library (DLL or SO, depending on which OS the applet is running on), that must be written to disk and subsequently loaded from the disk by a call…
2
votes
1 answer

git (git-bash) on windows locks number of folders even when done

I usually use git-bash to manage source code from my windows desktop. When I am done, I close the git-bash window or run the exit command. Then, I noticed that a good number of folders used for git projects are locked by git. The only way to release…
tarekahf
  • 738
  • 1
  • 16
  • 42