Question

HI all,

I have a text file which is a used by two applications.

Firstly a text file will be getting updated on a timely basis(say for 10 seconds) by an application built by java.

These details updated by text file will be used by our application which is built in c#. But an error is thrown whenever there is a clash between the two applications to have the control over the file.

We can make any changes with regard to our application built in c# but not the application built in java.

Can someone help me with this.

Note: The java application will write into the text file. But my c# application will read that text file.

No correct solution

OTHER TIPS

You can use the FileSystemWatcher class to determine when the file has been updated. In the event raised when it has been updated, either lock the file to your process only, or open it in shared mode.

As long as the file is being opened in a shared read mode by the Java application, then you can still read from it in your C# application:

var myFileStream = new FileStream("myfile.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var myFileReader = new StreamReader(myFileStream);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top