public static void CopyXslFile(string sReportFile)
{
// Note that this will not work in development because it depends
// upon the xsl file existing in the same location as the
// executing assembly, which is only true of the deployment package.
//
// During development, though, the file FontVal/fval.xsl can be
// copied as needed to
// FontVal/bin/Debug or
// FontVal/bin/Release
// and then the source file is found.
// build the src filename
string sAssemblyLocation =
System.Reflection.Assembly.GetExecutingAssembly().Location;
FileInfo fi = new FileInfo(sAssemblyLocation);
string sSrcDir = fi.DirectoryName;
string sSrcFile = sSrcDir + Path.DirectorySeparatorChar + "fval.xsl";
// build the dest filename
fi = new FileInfo(sReportFile);
string sDestDir = fi.DirectoryName;
string sDestFile = sDestDir + Path.DirectorySeparatorChar + "fval.xsl";
// copy the file
try
{
try
{
File.Copy(sSrcFile, sDestFile, true);
}
catch ( FileNotFoundException )
{
if ( !File.Exists( sDestFile ) )
File.WriteAllBytes(sDestFile, Compat.Xsl.fval);
}
fi = new FileInfo(sDestFile);
fi.Attributes = fi.Attributes & ~FileAttributes.ReadOnly;
if ( Type.GetType("Mono.Runtime") != null )
{
var xslTrans = new XslCompiledTransform();
xslTrans.Load(sDestFile);
string sHTMLFile = sReportFile.Replace(".report.xml", ".report.html");
if ( sHTMLFile != sReportFile )
try
{
xslTrans.Transform(sReportFile, sHTMLFile);
}
catch(Exception e)
{
}
}
}
catch (Exception)
{
}
}