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:
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

  • edited 4:03PM
    Hello,

    I've tried to insert your code in a simple project. It works well on my PC (WinXP) even if I produce an error.
  • edited 4:03PM
    AlexTZ wrote: »
    Hello,

    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?
  • edited 4:03PM
    Now I have tried to run it on Vista (I have no Win7 machine, sorry). I've made two tests (1st under admin account, 2nd under user account) - still no problems. Maybe I'm doing something wrong. Could you make a simple test project for me? You can send it to tz@fast-report.com.
  • edited 4:03PM
    AlexTZ wrote: »
    Now I have tried to run it on Vista (I have no Win7 machine, sorry). I've made two tests (1st under admin account, 2nd under user account) - still no problems. Maybe I'm doing something wrong. Could you make a simple test project for me? You can send it to tz@fast-report.com.
    Yes, but unfortunatley I'm out of time right now, so it will take a while to send it to you. I will leave you a notice when its done.
  • edited 4:03PM
    I ordered the full version of FastReport and it seems that the problem is no longer there.

    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

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.