AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi .txt Datei vom Server beziehen

.txt Datei vom Server beziehen

Ein Thema von larsder4 · begonnen am 28. Mai 2008 · letzter Beitrag vom 29. Mai 2008
Antwort Antwort
Seite 2 von 3     12 3   
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#11

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 21:50
Ziel := 'C:\index.html';
Markus Kinzler
  Mit Zitat antworten Zitat
Benutzerbild von Die Muhkuh
Die Muhkuh

Registriert seit: 21. Aug 2003
7.332 Beiträge
 
Delphi 2009 Professional
 
#12

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 21:51
Du musst halt schon ein Zieldateiname angeben
  Mit Zitat antworten Zitat
Benutzerbild von FAlter
FAlter

Registriert seit: 21. Jul 2004
Ort: Ostfildern
1.095 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#13

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 21:51
Hi,

1. ist Ziel ein Dateiname und
2. hab zumindest ich keine Schreibrechte auf C:\

Mfg
FAlter
Felix Alter
Japanurlaub 2015
  Mit Zitat antworten Zitat
larsder4

Registriert seit: 13. Feb 2008
Ort: Kellinghusen
24 Beiträge
 
#14

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:10
Es klappt immer noch nicht, irgendwas mache ich falsch.

Die Downloadzeit (falls es eine gibt) ist irsinnig schnell.

Hier ist mal der ganze Quelltext:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, XPMan, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP, UrlMon;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    XPManifest1: TXPManifest;
    StatusBar1: TStatusBar;
    Button1: TButton;
    Memo1: TMemo;
    Label2: TLabel;
    IdHTTP1: TIdHTTP;
    procedure FormCreate(Sender: TObject);
    procedure memo_nehmen(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
label2.Caption := '';
end;

procedure TForm1.memo_nehmen(Sender: TObject);
var
Quelle, Ziel: String;
begin
label2.Caption := (Sender as TButton).Caption;
Quelle := 'http://www.google.de/index.html';
Ziel := 'C:\Dokumente und Einstellungen\Computer\Eigene Dateien\Schule\Informatik\Delphi\Hausaufgaben\index.html';
UrlDownloadToFile(nil, PChar(Quelle), PChar(Ziel), 0, nil);

end;

end.
Ich habe Administrator Rechte, dann müsste ich auch alle Schreibrechte haben.
Ich kann meinen Fehler einfach nicht finden
Fehler vermeidet man, indem man Erfahrungen sammelt,
Erfahrungen sammelt man, indem man Fehler macht
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#15

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:13
Die Funktion funktioniert auch asynchron. Der letzte Parameter ist ein Callback. Diese wird aufgerufen, wenn sich der Status ändert. Wie ist der Returncode?
Markus Kinzler
  Mit Zitat antworten Zitat
larsder4

Registriert seit: 13. Feb 2008
Ort: Kellinghusen
24 Beiträge
 
#16

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:17
Gute Frage

Was genau ist ein Returncode?
Ich kenne diese Funktion erst seit 10 Minuten
Fehler vermeidet man, indem man Erfahrungen sammelt,
Erfahrungen sammelt man, indem man Fehler macht
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#17

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:21
Zitat von OH:
URLDownloadToFile Function

--------------------------------------------------------------------------------

Downloads bits from the Internet and saves them to a file.

Syntax

HRESULT URLDownloadToFile( LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);
Parameters

pCaller
Pointer to the controlling IUnknown interface of the calling Microsoft ActiveX component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download.
szURL
Pointer to a string value containing the URL to be downloaded. Cannot be set to NULL. If the URL is invalid, INET_E_DOWNLOAD_FAILURE is returned.
szFileName
Pointer to a string value containing the name of the file to create for bits that come from the download.
dwReserved
Reserved. Must be set to 0.
lpfnCB
Pointer to the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL.
Return Value

Returns one of the following values.

S_OK The operation succeeded.
E_OUTOFMEMORY The buffer length is invalid or there was insufficient memory to complete the operation.
INET_E_DOWNLOAD_FAILURE The download of the specified resource has failed.
Markus Kinzler
  Mit Zitat antworten Zitat
larsder4

Registriert seit: 13. Feb 2008
Ort: Kellinghusen
24 Beiträge
 
#18

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:26
Okay, da bin ich jetzt nicht so ganz durchgestiegen

Was sollte ich denn anstelle des letzen 'nil' schreiben?
Fehler vermeidet man, indem man Erfahrungen sammelt,
Erfahrungen sammelt man, indem man Fehler macht
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#19

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:27
Was liefert den die Funktion zurück?
Markus Kinzler
  Mit Zitat antworten Zitat
larsder4

Registriert seit: 13. Feb 2008
Ort: Kellinghusen
24 Beiträge
 
#20

Re: .txt Datei vom Server beziehen

  Alt 28. Mai 2008, 22:31
Bei mir ja anscheinend gar nichts.

Die Funktion sollte dazu dienen, dass eine Datei aus dem Internet aufm meinen Pc geladen wird. Wird da etwas gesendet???

Sorry, aber ich bin in diesem Punkt wirklich ein ziemlicher Anfänger.
Fehler vermeidet man, indem man Erfahrungen sammelt,
Erfahrungen sammelt man, indem man Fehler macht
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:06 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz