Ver Mensaje Individual
  #2  
Antiguo 19-09-2013
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Juanfish,

Cita:
Empezado por Juanfish
...el tema esta que esta aplicación funciona en dos ambientes distintos en la cual el usuario puede trabajar en una misma maquina, por lo tanto dependiendo del ambiente donde este trabajando los archivos se guardarían en una ruta u otra...
¡Bienvenido al Club Delphi!

Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  F1 : TStringList;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  SaveDialog : TSaveDialog;

begin

  SaveDialog := TSaveDialog.Create(self);
  SaveDialog.Title := 'Save your text or word file';
  SaveDialog.InitialDir := 'C:\RutaDefinida-1';
  SaveDialog.Filter := 'Text file|*.txt';
  SaveDialog.FileName := 'TestFile-1';
  SaveDialog.DefaultExt := 'txt';
  SaveDialog.FilterIndex := 1;

  if SaveDialog.Execute then
  begin
     F1.SaveToFile(SaveDialog.FileName);
     ShowMessage('File : ' + SaveDialog.FileName)
  end
  else
     ShowMessage('Save file was cancelled');

  SaveDialog.Free;

end;

procedure TForm1.Button2Click(Sender: TObject);
var
  SaveDialog : TSaveDialog;

begin

  SaveDialog := TSaveDialog.Create(self);
  SaveDialog.Title := 'Save your text or word file';
  SaveDialog.InitialDir := 'C:\RutaDefinida-2';
  SaveDialog.Filter := 'Text file|*.txt';
  SaveDialog.FileName := 'TestFile-2';
  SaveDialog.DefaultExt := 'txt';
  SaveDialog.FilterIndex := 1;

  if SaveDialog.Execute then
  begin
     F1.SaveToFile(SaveDialog.FileName);
     ShowMessage('File : ' + SaveDialog.FileName)
  end
  else
     ShowMessage('Save file was cancelled');

  SaveDialog.Free;

end;

procedure TForm1.FormCreate(Sender: TObject);
var
   i : Integer;
begin
   F1 := TStringList.Create;
   for i := 1 to 10 do
      F1.Add('Line-' + IntToStr(i));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   F1.Free;
end;

end.
El código anterior en Delphi 7 utiliza el componente TSaveDialog, funcionando según lo esperado en Windows 7 Professional x32 y x64.

Pregunto:

1- ¿Puedes explicar con más detalle el tema relacionado a los ambientes?.

2- ¿Hay algo en el cambio de ambiente que pueda afectar la selección del directorio asignado en el componente TSaveDialog?.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 19-09-2013 a las 21:38:59.
Responder Con Cita