Einzelnen Beitrag anzeigen

torud

Registriert seit: 26. Jul 2002
Ort: Sachsen
1.198 Beiträge
 
Delphi XE5 Professional
 
#18

Re: Datei kann nicht geschrieben werden - Warum und wie ände

  Alt 26. Okt 2006, 23:31
Hier nochmal mein kompletter Code, mit dem es immer noch nicht geht. Was mache ich nur falsch?
Delphi-Quellcode:
procedure Tcomplete.btn_generateClick(Sender: TObject);
var
  HtmlList,ContentList,FileList:TStringlist;
  str_head,str_content,sFileName:string;
  i,k,z,j,int_Count,int_cols,int_rows,int_filecounter_th,int_filecounter_td:integer;
begin
  if CreateIsRunning then
    Exit;

  CreateIsRunning := True;
  int_Count:=0;
  int_cols:=0;
  int_rows:=0;
  int_filecounter_th:=0;
  int_filecounter_td:=0;

  int_cols:=ed_cols.Value;
  ContentList:=TStringlist.Create;
  HtmlList:=TStringlist.Create;
  FileList:=TStringlist.Create;

  HtmlList.Add('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
  HtmlList.Add('<html>');
  HtmlList.Add('<head>');
  HtmlList.Add('<link rel="stylesheet" href="../css/'+cmb_css_file.Text+'" type="text/css" />');

  HtmlList.Add('</head>');
  HtmlList.Add('<body>');

    for i:=0 to form1.list_files.Count-1 do
      if form1.list_files.Checked[i] then
        begin
          inc(int_Count);
          FileList.Add(form1.ed_dir.Text + form1.list_files.items[i])
        end;

    case rad_artikel_style.ItemIndex of
      0 : begin
            for i:=0 to form1.list_files.Count-1 do
              begin
                if form1.list_files.Checked[i] then
                  begin
                    ContentList.LoadFromFile(form1.ed_dir.Text + form1.list_files.Items.Strings[i]);
                    str_head:=ContentList.Strings[0];
                    ContentList.Delete(0);
                    str_content:=ContentList.Text;
                    form1.GenerateFile(form1.ed_dir.Text + form1.list_files.Items[i],false,i);
                    SetLength(str_content,strtoint(ed_sign_count.text));
                    //hier wird das layout zusammengebaut
                            HtmlList.Add('');
                            HtmlList.Add('<h3>'+str_head+'</h3>');
                            HtmlList.Add('');
                            if chk_br_linktext.Checked then
                              HtmlList.Add('

'+str_content+'
[url="artikel_id_
'+inttostr(i)+'.html"]'+ed_linktext.Text+'[/url]</p>')
                            else
                              HtmlList.Add('

'+str_content+' [url="artikel_id_'+inttostr(i)+'.html"]'+ed_linktext.Text+'[/url]</p>');
                            HtmlList.Add('');
                    end;
                  end;
              end;
        1 : begin
              HtmlList.Add('<table cellpadding="3">');
              int_rows:=((int_Count div int_cols) + (int_Count mod int_cols));
              //arbeitet alle zeilen ab
              for k:=0 to int_rows-1 do
                begin
                  //arbeitet die th-spalten ab
                  HtmlList.Add(' <tr valign="top">');
                  for z:= 1 to int_cols do
                    begin
                      ContentList.Clear;
                      if int_filecounter_th<int_Count then
                        begin
                          ContentList.LoadFromFile(FileList.Strings[int_filecounter_th]);
                          str_head:=ContentList.Strings[0];
                          HtmlList.Add(' <th>'+str_head+'</th>');
                        end
                      else
                          HtmlList.Add(' <th></th>');
                      inc(int_filecounter_th);
                    end;
                  HtmlList.Add(' </tr>');
                  //arbeitet die td-spalten ab
                  HtmlList.Add(' <tr valign="top">');
                  for z:= 1 to int_cols do
                    begin
                      ContentList.Clear;
                      if int_filecounter_td<int_Count then
                        begin
                          ContentList.LoadFromFile(FileList.Strings[int_filecounter_td]);
                          ContentList.Delete(0);
                          str_content:=ContentList.Text;
                          form1.GenerateFile(FileList.Strings[int_filecounter_td],false,int_filecounter_td);
                          SetLength(str_content,strtoint(ed_sign_count.text));
                          HtmlList.Add(' <td>' +str_content+' [url="artikel_id_'+inttostr(int_filecounter_td)+'.html"]'+ed_linktext.Text+'[/url]</td>');
                        end
                      else
                          HtmlList.Add(' <td></td>');
                      inc(int_filecounter_td);
                    end;
                  HtmlList.Add(' </tr>');
                end;
            end;
    end;
    HtmlList.Add('</body>');
    HtmlList.Add('</html>');

    sFileName := Pvw_Path + 'index.html';

    if fileexists(sFileName) then
      DeleteFile(sFileName);
      sleep(60);


    try
      HtmlList.SaveToFile(sFileName);
      HtmlList.Clear;
      HtmlList.Free;
    except
      on e: exception do
      begin
        ShowMessage('error = ' + e.Message);
      end;
    end;
    web.Navigate(sFileName);
    {try
      HtmlList.SaveToFile(sFileName);
      web.Navigate(sFileName);
    finally}

      FileList.Free;
      //HtmlList.Free;
      ContentList.Free;
      CreateIsRunning:=False;
// end;
end;
Danke
Tom
  Mit Zitat antworten Zitat