Sharing data from two text file using by 2 application at same time

MARK

I have two WPF application i use the same text file in two applications when i want file to write from one application and read the data written from another application . but i can't do it because the two applications use the same file at same time . can any one help my to do it please . i write this code but don't make any thing :

try
{
    int nofiles = Directory.GetFiles("E:\\files", "*.txt").Length;
    nofiles++;
    StreamWriter write = new StreamWriter("E:\\files\\" + nofiles + ".txt");
    write.WriteLine(itemId);
    write.Close();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
App.Current.Shutdown();
Adil

You can use inter process synchronization using Mutex in both applications. Make sure you release Mutex as soon as possible. You need some thing like given below in all the processes accessing file to synchronize access.

Mutex m = new Mutex(false, "MyMutex");
m.WaitOne();
//File read or writing code goes here.   
m.ReleaseMutex(); 

Named system mutexes are visible throughout the operating system, and can be used to synchronize the activities of processes. You can create a Mutex object that represents a named system mutex by using a constructor that accepts a name, MSDN.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Sharing data from two text file using by 2 application at same time

From Dev

How to set two property value using groovy in the same time from a text file

From Dev

Java read two text file at the same time

From Dev

Reading and writing to the same file from two different scripts at the same time

From Dev

Logging Output of Console Application to a text file and Console Window at the same time

From Dev

Using Two "For" at the same time

From Dev

How to merge data from two text file

From Dev

Importing data from text file to two listboxes

From Dev

How to merge data from two text file

From Dev

Data sharing between two application in android

From Dev

Read a data from a text file and display data using SDI Application (MFC)?

From Dev

Using two databases at the same time with Symfony2

From Dev

Data extraction from a text file using bash

From Dev

Extracting data from text file using javascript

From Dev

Data extraction from a text file using bash

From Dev

Is it possible to save data to file using pipe and unzip it in same time?

From Dev

Is it possible to save data to file using pipe and unzip it in same time?

From Dev

Spark 2 application on the same time

From Dev

Importing data from text file and saving the same in excel

From Dev

How to plot real time data from text file in MATLAB

From Dev

Reading data from a text file, written in a specific period of time in Python

From Dev

data read from a text file into two lists in python

From Dev

Extract data between two patterns from a huge (forced) text file

From Dev

GreaseMonkey - sharing data between two scripts running in same tab

From Dev

Replacing two patterns in a text files at the same time

From Dev

Rename text that meets two criteria at the same time

From Dev

read string/character/data after specific searched string in same line only from a text file using C++

From Dev

Breakpoints in two applications sharing the same codebase using Xdebug

From Dev

Two android projects sharing common module in same repository using gradle

Related Related

  1. 1

    Sharing data from two text file using by 2 application at same time

  2. 2

    How to set two property value using groovy in the same time from a text file

  3. 3

    Java read two text file at the same time

  4. 4

    Reading and writing to the same file from two different scripts at the same time

  5. 5

    Logging Output of Console Application to a text file and Console Window at the same time

  6. 6

    Using Two "For" at the same time

  7. 7

    How to merge data from two text file

  8. 8

    Importing data from text file to two listboxes

  9. 9

    How to merge data from two text file

  10. 10

    Data sharing between two application in android

  11. 11

    Read a data from a text file and display data using SDI Application (MFC)?

  12. 12

    Using two databases at the same time with Symfony2

  13. 13

    Data extraction from a text file using bash

  14. 14

    Extracting data from text file using javascript

  15. 15

    Data extraction from a text file using bash

  16. 16

    Is it possible to save data to file using pipe and unzip it in same time?

  17. 17

    Is it possible to save data to file using pipe and unzip it in same time?

  18. 18

    Spark 2 application on the same time

  19. 19

    Importing data from text file and saving the same in excel

  20. 20

    How to plot real time data from text file in MATLAB

  21. 21

    Reading data from a text file, written in a specific period of time in Python

  22. 22

    data read from a text file into two lists in python

  23. 23

    Extract data between two patterns from a huge (forced) text file

  24. 24

    GreaseMonkey - sharing data between two scripts running in same tab

  25. 25

    Replacing two patterns in a text files at the same time

  26. 26

    Rename text that meets two criteria at the same time

  27. 27

    read string/character/data after specific searched string in same line only from a text file using C++

  28. 28

    Breakpoints in two applications sharing the same codebase using Xdebug

  29. 29

    Two android projects sharing common module in same repository using gradle

HotTag

Archive