Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FTP ActiveX in Delphi 3 Pro

Posted on 2000-03-11
12
Medium Priority
?
319 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
ID: 2607389
Listening..
0
 
LVL 1

Expert Comment

by:new_x
ID: 2608107
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
ID: 2609244
Adjusted points to 100
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:elkiors
ID: 2609245
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
ID: 2613088
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
ID: 2613122
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
ID: 2613132
Let me know the result (whether SUCCESS or FAILURE)
0
 

Author Comment

by:elkiors
ID: 2613706
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
ID: 2614731
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 300 total points
ID: 2657682
Hi ,

 Long time passed;
0
 

Author Comment

by:elkiors
ID: 2667096
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
ID: 2667635

Thnx for the points,

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

971 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