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...
The bin folder holds binary files, which are the actual executable code for your application or library. Each of these folders are further subdivided into Debug and Release folders, which simply correspond to the project's build configurations.
Open your project in Visual Studio > click the Show All Files button > expand the bin , Debug > select and right-click the parent folder > choose Include in Project option. 4).
There are two ways to open a folder in Visual Studio. In the Windows Explorer context menu on any folder, you can click “Open in Visual Studio”. Or on the File menu, click Open, and then click Folder. Recent folders will be persisted to the MRU.
When you create a new project, Visual Studio saves it to its default location, %USERPROFILE%\source\repos. To change this location, go to Tools > Options > Projects and Solutions > Locations.
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:
string executableLocation = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location); string xslLocation = Path.Combine(executableLocation, "docx.xsl");
You might need the following namespaces imported at the top of your file:
using System; using System.IO; using System.Reflection;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With