IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

[XE7] Transfert de fichier avec Indy


Sujet :

Langage Delphi

  1. #1
    Membre habitué
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2002
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2002
    Messages : 391
    Points : 189
    Points
    189
    Par défaut [XE7] Transfert de fichier avec Indy
    Bonjour

    Je suis encore en panne je me connecte a mon serveur FTP mais je dois y transferer un fichier qui inclus mon Login,usagé,mot-passe

    Pour me connecter je prend IdTcpClient mais dans toutes mes lectures il dise de prendre IdFtp et quand je l'utilise j'ai un erreur.

    Si vous avez une solution pour transferer un fichier en Ftp ou un autre composant qui remplace IdFtp dans Indy.


    Merci

    Mario

  2. #2
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    pourquoi vouloir prendre autre chose que TidFTP ?

    Avec un IdTcpClient, tu vas devoir coder TOUT le protocol FTP, c'est un gros travail !

    Le plus simple serait de nous indiquer l'erreur !

    J'utilise le TidFTP et je l'ai encaspulé dans une classe pour me faciliter la vie
    J'ai créé la toute première version de TSLTFTP lorsque le TNMFTP de Delphi 5 a disparu dans Delphi 7
    Du coup, j'avais anticipé une disparation du TIdFTP qui aurait encore nécessiter de changer le code de l'application
    Après tout, Delphi entre la 3 et la 7 nous avais habitué a des changements réguliers de bibliothèque
    finalement en presque 15 ans d'existence les évolutions de TIdFTP n'ont été que peu impactante

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    //------------------------------------------------------------------------------
    (*                SoLuTions is an Versatile Library for Delphi                 -
     *                                                                             -
     *  Copyright ou © ou Copr. "SLT Solutions", (2006)                            -
     *  contributeur : ShaiLeTroll (2006) - Migration TNMFTP vers TIdFTP lors du passge de Delphi 5 à Delphi 7
     *  contributeur : ShaiLeTroll (2006) - Séparation FTP et SFTP, pour supprimer la dépendance à SecureBlackBox et ne conserver que IdFTP fourni avec Delphi 7
     *  contributeur : ShaiLeTroll (2012) - Renommage Fichier et Correction XE2    -
     *  contributeur : ShaiLeTroll (2012) - Documentation Insight                  -
     *                                                                             -
     * Ce logiciel est un programme informatique servant à aider les développeurs  -
     * Delphi avec une bibliothèque polyvalente, adaptable et fragmentable.        -
     *                                                                             -
     * Ce logiciel est régi par la licence CeCILL-C soumise au droit français et   -
     * respectant les principes de diffusion des logiciels libres. Vous pouvez     -
     * utiliser, modifier et/ou redistribuer ce programme sous les conditions      -
     * de la licence CeCILL-C telle que diffusée par le CEA, le CNRS et l'INRIA    -
     * sur le site "http://www.cecill.info".                                       -
     *                                                                             -
     * En contrepartie de l'accessibilité au code source et des droits de copie,   -
     * de modification et de redistribution accordés par cette licence, il n'est   -
     * offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,   -
     * seule une responsabilité restreinte pèse sur l'auteur du programme,  le     -
     * titulaire des droits patrimoniaux et les concédants successifs.             -
     *                                                                             -
     * A cet égard  l'attention de l'utilisateur est attirée sur les risques       -
     * associés au chargement,  à l'utilisation,  à la modification et/ou au       -
     * développement et à la reproduction du logiciel par l'utilisateur étant      -
     * donné sa spécificité de logiciel libre, qui peut le rendre complexe à       -
     * manipuler et qui le réserve donc à des développeurs et des professionnels   -
     * avertis possédant  des  connaissances  informatiques approfondies.  Les     -
     * utilisateurs sont donc invités à charger  et  tester  l'adéquation  du      -
     * logiciel à leurs besoins dans des conditions permettant d'assurer la        -
     * sécurité de leurs systèmes et ou de leurs données et, plus généralement,    -
     * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.          -
     *                                                                             -
     * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez      -
     * pris connaissance de la licence CeCILL-C, et que vous en avez accepté les   -
     * termes.                                                                     -
     *                                                                             -
     *----------------------------------------------------------------------------*)
    unit SLT.Common.FTP;
     
    interface
     
    {*$DEFINE DEBUG_SLT_FTP*}
     
    uses System.Classes, System.SysUtils,
      IdFTP;
     
    type
      { Forward class declarations }
      TSLTFTP = class;
      TSLTFTPConnectionInfo = class;
     
      { class declarations }
     
      /// <summary>Encapsule une connection FTP avec un emplacement de travail prédéfini</summary>
      TSLTFTP = class(TObject)
      private
        // Membres privés
        FConnection: TIdFTP;
        FConnectionInfo: TSLTFTPConnectionInfo;
        FFiles: TStrings;
        FFileFilter: string;
     
        function InitializeFiles(): Boolean;
        function ChangeDirectory(const ADirectory: string): Boolean; overload;
        function ChangeDirectory(const ADirectory: string; out AOldDirectory: string): Boolean; overload;
     
        {$IFDEF DEBUG_SLT_FTP}
        procedure OutputDebugFTP(const Msg: string); inline;
        {$ENDIF DEBUG_SLT_FTP}
     
      protected
        // Accesseurs
        procedure SetConnectionInfo(Value: TSLTFTPConnectionInfo);
        function GetFileCount(): Integer;
        function GetFile(Index: Integer): TFileName;
        function GetFileSize(Index: Integer): Int64;
        procedure SetFileFilter(const Value: string);
      public
        // Constructeurs
        constructor Create();
        destructor Destroy(); override;
     
        // Méthodes
        function Connect(): Boolean;
        function Disconnect(): Boolean;
     
        function Get(const ASourceFile: string; ADest: TStream; const ASourceDirectory: string = ''): Boolean;
        function Put(const ASource: TStream; const ADestFile: string; const ADestDirectory: string = ''): Boolean;
        function RenameFile(const ASourceFile: string; const ADestFile: string): Boolean;
        function MoveFile(const ASourceFile: string; const ADestFile: string; const ASourceDirectory: string = ''; const ADestDirectory: string = ''): Boolean;
        function MoveFileTo(const AFile: string; const ADestDirectory: string; ReplaceExistring: Boolean = False): Boolean;
        function DeleteFile(const AFile: string; const ADirectory: string = ''): Boolean;
     
        // Propriétés
        property ConnectionInfo: TSLTFTPConnectionInfo read FConnectionInfo write SetConnectionInfo;
        property FileCount: Integer read GetFileCount;
        property Files[Index: Integer]: TFileName read GetFile;
        property FileSizes[Index: Integer]: Int64 read GetFileSize;
        property FileFilter: string read FFileFilter write SetFileFilter;
      end;
     
      /// <summary>Décrit un emplacement FTP</summary>
      TSLTFTPConnectionInfo = class(TPersistent)
      public
        const
          DEFAULT_PORT_FTP = 21;
      private
        // Membres privés
        FHost: string;
        FPort: Word;
        FDirectory: TFileName;
        FUser: string;
        FPassword: string;
      public
        // Constructeurs
        constructor Create();
     
        // Méthodes - Redéfinition de TPersistent
        procedure Assign(Source: TPersistent); override;
        // Méthodes - Redéfinition de TObject
        function ToString(): string; override;
     
        // Propriétés
        property Host: string read FHost write FHost;
        property Port: Word read FPort write FPort default DEFAULT_PORT_FTP;
        property Directory: TFileName read FDirectory write FDirectory;
        property User: string read FUser write FUser;
        property Password: string read FPassword write FPassword;
      end;
     
    implementation
     
    {$IFDEF DEBUG_SLT_FTP}
    uses
      SLT.Common.Tracing;
    {$ENDIF DEBUG_SLT_FTP}
     
    { TSLTFTP }
     
    //------------------------------------------------------------------------------
    function TSLTFTP.ChangeDirectory(const ADirectory: string): Boolean;
    begin
      FConnection.ChangeDir(ADirectory);
      Result := SameText(FConnection.RetrieveCurrentDir, ADirectory);
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.ChangeDirectory(const ADirectory: string; out AOldDirectory: string): Boolean;
    var
      OldD: string;
    begin
      OldD := FConnection.RetrieveCurrentDir;
      Result := ChangeDirectory(ADirectory);
      if Result then
        AOldDirectory := OldD;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.Connect(): Boolean;
    begin
      Result := False;
     
      Disconnect();
     
      FConnection.Host := FConnectionInfo.Host;
      FConnection.Port := FConnectionInfo.Port;
      FConnection.Username := FConnectionInfo.User;
      FConnection.Password := FConnectionInfo.Password;
     
      try
        FConnection.Connect();
        if FConnection.Connected then
        begin
          if FConnectionInfo.Directory <> '' then
            Result := ChangeDirectory(FConnectionInfo.Directory)
          else
            Result := True;
        end
        else
          Abort;
      except
        on E: Exception do
        begin
          {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('Connect : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
        end;
      end;
    end;
     
    //------------------------------------------------------------------------------
    constructor TSLTFTP.Create();
    begin
      inherited Create();
     
      FConnection := TIdFTP.Create(nil);
      FConnectionInfo := TSLTFTPConnectionInfo.Create();
      FFileFilter := '.';
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.DeleteFile(const AFile: string; const ADirectory: string = ''): Boolean;
    var
      lDel: string;
    begin
      if FConnection.Connected then
      begin
        try
          if ADirectory <> '' then
            lDel := ADirectory + '/' + AFile
          else
            lDel := AFile;
     
          if FConnection.Size(lDel) >= 0 then
            FConnection.Delete(lDel);
     
          Result := True;
        except
          on E: Exception do
          begin
            {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('DeleteFile : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
            Result := False;
          end;
        end;
      end
      else
        Result := False;
    end;
     
    //------------------------------------------------------------------------------
    destructor TSLTFTP.Destroy();
    begin
      Disconnect();
     
      FreeAndNil(FConnectionInfo);
      FreeAndNil(FConnection);
     
      inherited Destroy();
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.Disconnect(): Boolean;
    begin
      FreeAndNil(FFiles);
     
      try
        if FConnection.Connected then
        begin
          FConnection.Disconnect();
          Result := not FConnection.Connected;
        end
        else
          Result := True;
      except
        on E: Exception do
        begin
          {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('Disconnect : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
          Result := False;
        end;
      end;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.Get(const ASourceFile: string; ADest: TStream; const ASourceDirectory: string = ''): Boolean;
    var
      OldDirectory: string;
    begin
      if FConnection.Connected then
      begin
        try
          if ASourceDirectory <> '' then
            if not ChangeDirectory(ASourceDirectory, OldDirectory) then
              Abort;
     
          try
            FConnection.Get(ASourceFile, ADest);
            Result := True;
          finally
            if (ASourceDirectory <> '') and (OldDirectory <> '') then
              if not ChangeDirectory(OldDirectory) then
                Abort;
          end;
        except
          on E: Exception do
          begin
            {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('Get : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
            raise;
          end;
        end;
      end
      else
        Result := False;
    end;
     
     
    //------------------------------------------------------------------------------
    function TSLTFTP.GetFile(Index: Integer): TFileName;
    begin
      if InitializeFiles() then
        Result := FFiles.Strings[Index]
      else
        Result := '';
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.GetFileCount(): Integer;
    begin
      if InitializeFiles() then
        Result := FFiles.Count
      else
        Result := 0;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.GetFileSize(Index: Integer): Int64;
    begin
      if InitializeFiles() then
        Result := FConnection.Size(Files[Index])
      else
        Result := 0;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.InitializeFiles(): Boolean;
    var
      TmpList: TStrings;
    begin
      Result := False;
      if FConnection.Connected then
      begin
        if not Assigned(FFiles) then
        begin
          TmpList := TStringList.Create();
          try
            try
              FConnection.List(TmpList, FFileFilter, False);
              if TmpList.Count > 0 then
              begin
                FFiles := TmpList;
                Exit(True);
              end;
            except
              on E: Exception do
              begin
                {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('InitializeFiles : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
                Result := False;
              end;
            end;
          finally
            if not Result then
              TmpList.Free();
          end;
        end;
      end;
     
      Result := Assigned(FFiles) and (FFiles.Count > 0);
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.MoveFile(const ASourceFile: string; const ADestFile: string; const ASourceDirectory: string = ''; const ADestDirectory: string = ''): Boolean;
    var
      lSrc, lDst: string;
    begin
      if FConnection.Connected then
      begin
        try
          if ASourceDirectory <> '' then
            lSrc := ASourceDirectory + '/' + ASourceFile
          else
            lSrc := ASourceFile;
     
          if ADestDirectory <> '' then
            lDst := ADestDirectory + '/' + ADestFile
          else
            lDst := ADestFile;
     
          FConnection.Rename(lSrc, lDst);
          Result := True;
        except
          on E: Exception do
          begin
            {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('MoveFile : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
            Result := False;
          end;
        end;
      end
      else
        Result := False;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.MoveFileTo(const AFile: string; const ADestDirectory: string; ReplaceExistring: Boolean = False): Boolean;
    begin
      if ReplaceExistring then
        DeleteFile(AFile, ADestDirectory);
     
      Result := MoveFile(AFile, AFile, '', ADestDirectory);
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.Put(const ASource: TStream; const ADestFile: string; const ADestDirectory: string = ''): Boolean;
    var
      OldDirectory: string;
    begin
      if FConnection.Connected then
      begin
        try
          if ADestDirectory <> '' then
            if not ChangeDirectory(ADestDirectory, OldDirectory) then
              Abort;
     
          try
            FConnection.Put(ASource, ADestFile);
            Result := True;
          finally
            if (ADestDirectory <> '') and (OldDirectory <> '') then
              if not ChangeDirectory(OldDirectory) then
                Abort;
          end;
        except
          on E: Exception do
          begin
            {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('Put : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
            Result := False;
          end;
        end;
      end
      else
        Result := False;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTP.RenameFile(const ASourceFile, ADestFile: string): Boolean;
    begin
      if FConnection.Connected then
      begin
        try
          FConnection.Rename(ASourceFile, ADestFile);
          Result := True;
        except
          on E: Exception do
          begin
            {$IFDEF DEBUG_SLT_FTP}OutputDebugFTP('RenameFile : ' + E.Message);{$ENDIF DEBUG_SLT_FTP}
            Result := False;
          end;
        end;
      end
      else
        Result := False;
    end;
     
    //------------------------------------------------------------------------------
    procedure TSLTFTP.SetConnectionInfo(Value: TSLTFTPConnectionInfo);
    begin
      FConnectionInfo.Assign(Value);
    end;
     
    //------------------------------------------------------------------------------
    procedure TSLTFTP.SetFileFilter(const Value: string);
    begin
      if not SameText(FFileFilter, Value) then
      begin
        FFileFilter := Value;
        FreeAndNil(FFiles);
      end;
    end;
     
    //------------------------------------------------------------------------------
    {$IFDEF DEBUG_SLT_FTP}
    procedure TSLTFTP.OutputDebugFTP(const Msg: string);
    begin
      TSLTDebugLogger.OutputDebugString('[SLT.FTP]', Format('%0:s : %1:s', [ConnectionInfo.Host, Msg]));
    end;
    {$ENDIF DEBUG_SLT_FTP}
     
     
    { TSLTFTPConnectionInfo }
     
    //------------------------------------------------------------------------------
    procedure TSLTFTPConnectionInfo.Assign(Source: TPersistent);
    begin
      if Source is TSLTFTPConnectionInfo then
      begin
        with TSLTFTPConnectionInfo(Source) do
        begin
          Self.FHost := FHost;
          Self.FPort := FPort;
          Self.FDirectory := FDirectory;
          Self.FUser := FUser;
          Self.FPassword := FPassword;
        end;
      end
      else
        inherited Assign(Source);
    end;
     
    //------------------------------------------------------------------------------
    constructor TSLTFTPConnectionInfo.Create();
    begin
      inherited Create();
     
      FPort := DEFAULT_PORT_FTP;
    end;
     
    //------------------------------------------------------------------------------
    function TSLTFTPConnectionInfo.ToString(): string;
     
      function ExcludeFirstPathDelimiter(const S: string): string;
      begin
        if IsDelimiter(S, '/', 1) then
          Result := Copy(S, 2, Length(S) - 1)
        else
          Result := S;
      end;
     
    begin
      // Concaténation des informations de connexion sous la forme d'une URL "ftp://user@ftpserver/url-path"
      Result := Format('ftp://%s@%s/%s', [User, Host, ExcludeFirstPathDelimiter(Directory)]);
    end;
     
    end.
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  3. #3
    Membre habitué
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2002
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2002
    Messages : 391
    Points : 189
    Points
    189
    Par défaut [XE7-indy]Transfert de fichier
    Merci de votre aide M.ShaLeTroll

    Mon code d'erreur quand j'utilise IdFtp

    Nom : erreur.JPG
Affichages : 401
Taille : 30,5 Ko

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    begin
     
    IdFtp1.Host:='192.168.1.134';
    IdFtp1.Port:=2131;
     
    try
    IdFtp1.Connect;
    except
        on E : Exception do
        ShowMessage('Message : ' + E.Message);
     
    end;
    Suite a plusieurs recherche j'ai essayé IdTcpClient je n'ai pas d'ereur

    Merci encore de votre aide je vérifie votre porgramme

    Mario

  4. #4
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 459
    Points : 24 873
    Points
    24 873
    Par défaut
    Tu te connecte SANS mot de passe ?

    AVAN cela ressemblerait plus à une commande qu'à une réponse qui sont normalement sur 3 chiffres !

    Avec IdTcpClient, tu envoies quoi ?
    Tu génère manuellement la trame FTP sur un composant TCP ?
    ça donne quoi comme buffer ? c'est des trucs genre STOR ... ???
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  5. #5
    Membre habitué
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2002
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2002
    Messages : 391
    Points : 189
    Points
    189
    Par défaut [XE7-indy]Transfert de fichier
    Merci de m'aider

    Le serveur FTP est un serveur tier qui sert a se connecter a un logiciel de comptabilite via FTP.

    Historique de mon besoin

    Au départ je transfert les informations directement dans les tables concernés mais je peux utilisé leur SDK qui est plus sécuritaire
    mais voulant transporté mon logiciel de Xe2 a Xe7 j'ai plus acces a mes composants pour manipuler les index CDX et tables DBF.
    Pas de probleme avec les tables mais je ne suis plus capable d'inclure les index j'ai essayé de compilé mes composants halcyon avec Xe7 et
    j'ai beaucoup d'erreur donc j'aimerais abandonné ce composant et utilisé le SDK(logiciel de comptabilité) qui garantie la qualité des informations transferés par mon programme.

    C'est sur que je pourrais continuer des recherches pour modifier halcyon il me reste 25% a verifier mais des composants autre dure un temp
    par la suite on est pris avec je pense apres plus de 10 ans il a fait le travail et le mettre a la retraite.



    Donc Je dois me connecter via FTP et par la suite transferer en ftp un fichier qui contient mon

    Login,no cie,usager,mot passe
    quand j'utilise IdTcpClient j'ai pas de probleme a me connecter mais ne peut transferer le fichier FTP du login

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    procedure TForm1.Button2Click(Sender: TObject);
    begin
     
    IdTCPCLIENT1.Host:='192.168.1.134';
    IdTCPCLIENT1.Port:=2131;
     
    try
    IdTCPCLIENT1.Connect;
    except
        on E : Exception do
        ShowMessage('Message : ' + E.Message);
     
    end;
    end;

    C'est le meme code que IdFtp

    J'espere que ca peut mieux vous renseigné sur mon besoin

    Merci encore

    Mario

  6. #6
    Membre habitué
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2002
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2002
    Messages : 391
    Points : 189
    Points
    189
    Par défaut [XE7] Transfert de fichier avec Indy
    Merci de votre aide

    J'ai trouvé le bon composant qui fait ce que j'ai besoin soit envoyé des lignes de commande au serveur FTP

    Soit le composant Indy IdIdent

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
        With IdIdent1 Do
                Begin
                  // envoie message
                  IOHandler.WriteLn(code_facture);
                  // reception de confirmation
                  l_response:= IdIdent1.IoHandler.Readln;
                 end;
               // affiche dans memo la réception du message
               Memo2.Lines.Add(l_response);
    Merci encore

    Mario

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Transfert de fichier avec wagon
    Par hugo123 dans le forum Maven
    Réponses: 9
    Dernier message: 24/05/2007, 11h16
  2. transfert de fichier avec un socket
    Par horkets dans le forum Réseau
    Réponses: 2
    Dernier message: 22/10/2006, 12h29
  3. Probleme transfert gros fichier avec webdav
    Par cybernetique dans le forum Apache
    Réponses: 1
    Dernier message: 10/05/2006, 09h53
  4. Envoi de fichier avec Indy
    Par Nicodemus dans le forum Web & réseau
    Réponses: 2
    Dernier message: 28/10/2005, 15h29
  5. Transfert de fichier avec TServeurSocket et TClientSocket
    Par Cyrilh7 dans le forum C++Builder
    Réponses: 7
    Dernier message: 24/09/2005, 17h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo