locked
Using the same XML for more than one EXE? RRS feed

  • General discussion

  • Hi all of you,

    My platform consists in three EXE.  From the main one the end user defines one image as logo of its organizatin (both Logon WinForm and About us Winform) and such info is saved on a XML configuration file (no app.config), that's one separately.

    I would like to recover this info from the rest of EXE apps but using the same XML (it is in the same folder)

    How can I do this? The way I do is deserializing my XML file into a class and then serializing back by a StreamWriter.

    I will get a lock whether allow to both EXE access at the same time to that XML

    I don't want to change this way and moving data to Sql table

    Any help would be greatly appreciated,


    Enric


    • Edited by Enric Vives Monday, September 24, 2012 10:46 PM
    Monday, September 24, 2012 10:36 PM

All replies

  • Hi Enric,

    Thank you for posting here.

    When a streamWriter writer a file, the file will be locked. This feature is by design. So I suggest you try this workaround:

    1. query the other two exes, to make sure they don't use the xml file.

    2. If they are using it, wait some times.

    3. If not, begin your business.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 25, 2012 10:16 AM
  • Hi Mike,

    How can I develop this point: "2. If they are using it, wait some times."

    TIA,


    Enric

    Tuesday, September 25, 2012 10:45 AM
  • Hi Mike,

    How can I develop this point: "2. If they are using it, wait some times."

    TIA,


    Enric

    Hi Enric,

    Please try Thread.Sleep(some time): http://msdn.microsoft.com/en-us/library/system.threading.thread.sleep(v=vs.110).aspx 

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, September 26, 2012 2:49 AM