Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 05-10-2008
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.141
Poder: 36
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Aún habrá más formas, además de que no esté todo dicho, pero, vamos:

Código Delphi [-]
uses
  SysUtils;

const
  EXAMPLE_FILE_NAME = 'example.txt';
  STRING_TO_COMPARE = 'Content of example.txt';
  STRING_EQUALS_MSG = 'Ok, the string are the same';
  STRING_DIFFER_MSG = 'No, differents strings here';

// Una posible forma leer el archivo y accedera su contenido

procedure TForm1.Button1Click(Sender: TObject);
var
  fs: TFileStream;
  ss: TStringStream;
begin
  fs := TFileStream.Create(
    ExtractFilePath(ParamStr(0))+EXAMPLE_FILE_NAME,
    fmOpenRead
  );
  ss := TStringStream.Create(EmptyStr);
  try
    ss.CopyFrom(fs, fs.Size);
    if(ss.DataString = STRING_TO_COMPARE)then
      ShowMessage(STRING_EQUALS_MSG)
    else
      ShowMessage(STRING_DIFFER_MSG);
  finally
    fs.Free();
    ss.Free();
  end;
end;

// Otra posible forma leer el archivo y accedera su contenido

procedure TForm1.Button2Click(Sender: TObject);
var
  s: string;
  tf: TextFile;
begin
  AssignFile(tf, ExtractFilePath(
    ParamStr(0))+EXAMPLE_FILE_NAME);
  Reset(tf);
  while not Eof(tf) do
    ReadLn(tf, s);
  CloseFile(tf);
  if(s = STRING_TO_COMPARE)then
    ShowMessage(STRING_EQUALS_MSG)
  else
    ShowMessage(STRING_DIFFER_MSG);
end;

// Otra posible forma leer el archivo y accedera su contenido

procedure TForm1.Button3Click(Sender: TObject);
var
  sl: TStringList;
begin
  sl := TStringList.Create();
  try
    sl.LoadFromFile(ExtractFilePath(
      ParamStr(0))+EXAMPLE_FILE_NAME);
    if(Trim(sl.Text) = STRING_TO_COMPARE)then
      ShowMessage(STRING_EQUALS_MSG)
    else
      ShowMessage(STRING_DIFFER_MSG);
  finally
    sl.Free();
  end;
end;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Acceder al contenido de un word hcalero Servers 2 22-08-2007 13:07:09
Acceder al contenido de la memoria RAM Elias_02 API de Windows 0 08-11-2006 20:17:43
¿Crear email con imagen como parte del contenido del texto? burasu Varios 6 07-04-2006 19:11:30
Como puedo grabar texto en un Archivo de Texto sin Sobreescribir???? AGAG4 Varios 12 08-11-2005 22:53:00
Acceder al contenido de una celda en un DBGRID... Sinaloense OOP 2 22-09-2004 10:01:06


La franja horaria es GMT +2. Ahora son las 05:26:23.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi