Question

I added a Xml Schema to my Visual Studio project called "FaxTemplateXMLSchema.xsd" I'm now trying to reference that schema to do validation. I have a function that takes the filepath of a schema to reference it and validate, the only problem is I can't figure out the relative filepath. The full file path is "C:\Users\ccoleman\Documents\Visual Studio 2010\Projects\FaxTemplateConverter\FaxTemplateConverter\FaxTemplateXMLSchema.xsd" I'm attempting to not hardcode it in and would like to reference it something like this. String schemaFile = "..\\FaxTemplateXMLSchema.xsd"; if I use Directory.GetCurrentDirectory() I get the network drive "N:\" and Path.GetFullPath("FaxTemplateXMLSchema.xsd") gets me N:\FaxTemplateXMLSchema.xsd Edit: I ended up just adding string in the resources that is easily changed.

Was it helpful?

Solution

If you want to make it deployment agnostic, the something like

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

will give you the folder your code is executing from then work out where you want to be from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top