简体   繁体   中英

VBScript & C# Read/Write XML WITHOUT locking file

Scenario:

  1. Network User logs in to Domain
  2. Group Policy runs a VBScript
  3. VBScript reads from an XML
  4. VBScript performs operations based in information obtained from XML

What VBScript method(s) should I use so that over a network with multiple users accessing the XML at the same time I will not be prone to file locking issues?

If I made a C# program to read-in and modify the existing XML file from a network location during operation hours (at the same time the XML is being read from) which C# methods should I use to read/write to the XML without causing locking issues?

For the C# program accessing the XML file you can do the following:

  1. To handle XML file read/write requests use backgroundWorker component
  2. add all the corresponding event handlers to know about progress updates etc.
  3. call RunWorkerAsync to start read/write operation.

Source : MSDN

I not see why this s'd be so complicated. Just operate with 2 files.

  • VBScript read from file A1.xml
  • C# program write/update file A2.xml and then done replace A1.xml

And the vbs may look like...

Set xmlDoc   = CreateObject("Msxml2.DOMDocument.6.0")
xmlDoc.Async = False
bReturn      = False
Do Until bReturn
    WScript.Sleep 3500
    bReturn = xmlDoc.Load(".../A1.xml")
Loop
'...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM