Designer: Can't save report. The file may be write-protected.
Hello
I have the demo version of FastReport .NET. I have a problem when I call the designer from code and finally want to save the report. Then sometimes I get the error message:
"Can't save report. The file may be write-protected."
What I do is the following:
- Create FastReport instance.
- Check if the report-file exists. If not, I try to copy a "template" report so that the user has something to start with.
- Loading the report.
- Registering the DataSources.
- Running the Designer.
I use the following code:
I figured out, that I can save without a problem as long as there is no error in the report. When I produce an error I'm no longer able to save the report under the same filename (e.g. "Cell850: error CS0103: "some description"). Even when I fix the problem the designer gives me the error message: "Can't save report. The file may be write-protected."
Did I do anything wrong? Maybe I misunderstood something.
Thank's for helping.
Uwe
I have the demo version of FastReport .NET. I have a problem when I call the designer from code and finally want to save the report. Then sometimes I get the error message:
"Can't save report. The file may be write-protected."
What I do is the following:
- Create FastReport instance.
- Check if the report-file exists. If not, I try to copy a "template" report so that the user has something to start with.
- Loading the report.
- Registering the DataSources.
- Running the Designer.
I use the following code:
private void Test()
{
using (FastReport.Report report = new FastReport.Report())
{
if (!System.IO.File.Exists(_ReportFilename))
{
if (!System.IO.File.Exists(_TemplateFilename))
{
LOG.Error("Unable to find valid report-template: {0}", _TemplateFilename);
return false;
}
System.IO.File.Copy(_TemplateFilename, _ReportFilename, true);
}
report.Load(_ReportFilename);
if (OnRegisterData(report))
{
return report.Design();
}
}
}
protected virtual bool OnRegisterData(FastReport.Report report)
{
//Method to register DataSources fpr inherited classes.
return true;
}
I figured out, that I can save without a problem as long as there is no error in the report. When I produce an error I'm no longer able to save the report under the same filename (e.g. "Cell850: error CS0103: "some description"). Even when I fix the problem the designer gives me the error message: "Can't save report. The file may be write-protected."
Did I do anything wrong? Maybe I misunderstood something.
Thank's for helping.
Uwe
Comments
I've tried to insert your code in a simple project. It works well on my PC (WinXP) even if I produce an error.
I have Windows7 Pro, may be that's the problem? Maybe I should try to run the software with admin rights?
I tried to create a small example but was unable to recreate the problem. When I find out any new information I will let you know about it. For now you can consider this issue as "invalid".
Thank you for helping
Uwe