I have my docx.xsl file in my project/bin/debug folder.Now i want to access this file whenever i needed.But i could not able to access this file.
WordprocessingDocument wordDoc = WordprocessingDocument.Open(inputFile, true);
MainDocumentPart mainDocPart = wordDoc.MainDocumentPart;
XPathDocument xpathDoc = new XPathDocument(mainDocPart.GetStream());
XslCompiledTransform xslt = new XslCompiledTransform();
string xsltFile = @"\\docx.xsl"; // or @"docx.xsl";
xslt.Load(xsltFile);
XmlTextWriter writer = new XmlTextWriter(outputFile, null);
xslt.Transform(xpathDoc, null, writer);
writer.Close();
wordDoc.Close();
Please Guide me to put correct valid path to access docx.xsl file…
You can determine the location of your executable, and assuming the file will be deployed with the application to the relevant directory, then this should help you find the file in debugging and in deployment:
You might need the following namespaces imported at the top of your file: