I am working on an application on an aplication in which multiple users update a xsl during their processing.This file is placed on a folder on server where web application is deployed.
Following code is used to update the xsl file.
XmlDocument doc = new XmlDocument();
doc.Load(ConfigurationManager.AppSettings["XSLPdfDimensions"]);
XmlNode root = doc.DocumentElement;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
root.SelectSingleNode(marginTop, nsmgr).Attributes["select"].Value = Convert.ToString(top);
root.SelectSingleNode(marginBottom, nsmgr).Attributes["select"].Value = Convert.ToString(bottom);
doc.Save(ConfigurationManager.AppSettings["XSLPdfDimensions"]);
When users access this file concurrently following exception occurs
"The process cannot access the file 'C:\XSL\Dimensions.xsl'because it is being used by another process"
How to resolve this issue by minimum delay in functionality or there is some alternative approach for updating xsl file ?
Why not pass in the marginTop and marginBottom through code as parameters. That way you have one XSL, no modifications are required and all users get what they want.
Or modify the XML to pass in those values and rewrite the XSL to use those values from the XML. There should be no reason for user modification of the XSL in a well designed system. Either the XML or a parameter passed to the transformation can handle that variable information.
Since I see you are trying to pass PDF dimensions, you should look at the code here at http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage. If you look into that code you can get to the XSL behind that conversion. All of the appropriate page dimensions -- page size, all margins and many, many more things are all passed into that XSL from the XML (derived from the HTML div and/or specified in the Javascript and attached to the XML sent to the XSL).
There is no need for anyone to edit that XSL to get all kinds of things -- page sizes, margins, background images, page borders, page background colors, etc.