Solved

FTP ActiveX in Delphi 3 Pro

Posted on 2000-03-11
12
309 Views
Last Modified: 2010-08-05
I'm having a problem using the FTP ActiveX control in Delphi 3 Pro.
I've managed to connect and download a file but I get an EFOpenError in this section of code when I try to load the file into the memo control. I can see the file on the desktop and I can open it with Notepad, so what's going on.

procedure TfrmTest.FTP1DocOutput(Sender: TObject;
  const DocOutput: DocOutput);
begin
  case DocOutput.State of
    icDocEnd:
    begin
      memo1.Lines.LoadFromFile('c:\windows\desktop\V.txt');
    end;
  end;
end;

everyone's thoughts are appreciated, I can up the points if required.
0
Comment
Question by:elkiors
  • 7
  • 4
12 Comments
 
LVL 7

Expert Comment

by:Motaz
Comment Utility
Listening..
0
 
LVL 1

Expert Comment

by:new_x
Comment Utility
In fact LoadFromFile simply calls the
TFilestream constructor with the arguments
  TFileStream.Create(FileName, fmOpenRead or fmShareDenywrite);

if you get exception from this call
this means that whether you supplied an invalid filename (there is no file by that name.) or the file could not be opened with fmShareDenywrite mode constant.

(PS: I recommend that you use FPiette ' s ICS components which also includes ftp component which is not an ActiveX, full source code and sample programs available www.rtfm.be/fpiette/indexuk.htm)


Regards,

0
 

Author Comment

by:elkiors
Comment Utility
Adjusted points to 100
0
 

Author Comment

by:elkiors
Comment Utility
new-x:

thanks for the link, is there any way I can get around my problem using the default component. One thing that puzzled me was that LoadFromFile doesn't throw the error if I add a showmessage(''); just before it. which would indicate a timing problem, however if I add a Sleep(5000) just before it, the error still occurs. How would I open the file with different access rights ? I can get away with just loading into a TStringList if the solution is easier that way.

BTW I've doubled the points.

regards

Darren
0
 
LVL 1

Expert Comment

by:new_x
Comment Utility
Hi,

 delete the Memo1.Lines.LoadFromfile statement and put these lines(before doing that declare FHandle variable as
 FHandle: THAndle;
)

     
FHandle:= CreateFile(
PChar('c:\windows\desktop\V.txt'),    GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);

if(FHandle<>INVALID_HANDLE_VALUE) then begin
      ShowMessage('SUCCESS');
      CloseHandle(FHandle);
end
else
      ShowMessage('FAILURE');


Regards,
0
 
LVL 1

Expert Comment

by:new_x
Comment Utility
Hi,

 delete the Memo1.Lines.LoadFromfile statement and put these lines(before doing that declare FHandle variable as
 FHandle: THAndle;
)

     
FHandle:= CreateFile(
PChar('c:\windows\desktop\V.txt'),    GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);

if(FHandle<>INVALID_HANDLE_VALUE) then begin
      ShowMessage('SUCCESS');
      CloseHandle(FHandle);
end
else
      ShowMessage('FAILURE');


Regards,
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Expert Comment

by:new_x
Comment Utility
Let me know the result (whether SUCCESS or FAILURE)
0
 

Author Comment

by:elkiors
Comment Utility
Hi,

thanks for getting back, unfortunately, I downloaded the ICS suite as you suggested, and I got the FTP client in that suite working first time! however I unwittingly overwrote my original test project for the activex version, however I will reconstruct it in the name of research, you'll have to bear with me for a few days though as I've just bought myself the bits for a new machine, this P150 has got a little two long in the tooth. the points will be yours if I get a SUCCESS. If I get a FAILURE you'll still get the points for passing me the link for the ICS, it's excellent. I'll let you know the outcome.

Kindest regards

Darren
0
 
LVL 1

Expert Comment

by:new_x
Comment Utility
by using Fpiette's component you did the right thing :-), I have been using his components for two years. He also has a mailing list, If you have further questions I recommend you subscribe the list. Using ActiveX has disadvantages. (You have to load and register the activex for every computer that uses your program)

Regards,
0
 
LVL 1

Accepted Solution

by:
new_x earned 100 total points
Comment Utility
Hi ,

 Long time passed;
0
 

Author Comment

by:elkiors
Comment Utility
Hi new_x

Just got my email back up and running, so responded straight away.

I'm really sorry it's taken so long for me to get back round to this, I've had to rebuild my new system TWICE. W98 sucks at times :-(

Having done all that I haven't had a chance to recreate my original test and therefore have'nt tried to implement your coding work-around for the bundled FTP client, however your info for the link to the ICS suite of components has proved a perfect solution so the points are yours. Please accept my apologies for not acting on your coding ... a bit low-level for me to fully appreciate, but that's my fault not yours.

Thanx again for all your help and tips.

Regards

Darren
0
 
LVL 1

Expert Comment

by:new_x
Comment Utility

Thnx for the points,

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now