Board index » delphi » 2 questions -FILESIZE & SHELLEXECUTE

2 questions -FILESIZE & SHELLEXECUTE

hi :o)

I have to questions in Delhpi 1...

1) is it possible to get the file size of a TEXTFILE, I know it can't be
done using FILESIZE, but is there any other way ??

2) I am trying to launch and URL in windows 95, I am using the Shell
Execute command, so windows 95 looks at the file name to see what to open,
in this case the default web brouser, but it does not work !!!!

I know I am using the fuction correct since it works perfect on TXT files,
Notepad is opened and the TXT file loaded, the same goes for MID files,
Media Player is opened and the MID file is loaded, but it does not work
with an URL or a DOC, in both cases I get error 8 "There was insufficient
memory to start the application.", why is this ?? and do you know a
solution

if you can help me then please mail to Darkside_of_the_M...@MSN.COM

Thank you very much

Alex

 

Re:2 questions -FILESIZE & SHELLEXECUTE


Quote
> I have to questions in Delhpi 1...
> 1) is it possible to get the file size of a TEXTFILE, I know it can't be
> done using FILESIZE, but is there any other way ??

> if you can help me then please mail to Darkside_of_the_M...@MSN.COM
> Thank you very much
> Alex

You can get the size of a text file in bytes by opening it as a file of byte :

function FileSize(FileName: string): longint;
var
  F: file of byte;
begin
  Result := -1;
  try
    AssignFile(F, MyFileName);
    Reset(F);
    Result := FileSize(F);
  finally
    FileClose(F);
  end;
end;

Bear in mind that this size will include CR/LFs and the EOF (^Z) marker (if
present).

Greg Mockler
Pietermaritzburg, South Africa
g...@innovative.co.za

Re:2 questions -FILESIZE & SHELLEXECUTE


In article <01bbe598$f5aa77c0$5d4697c2@alexkaam>,
   "Alex" <Darkside_of_the_M...@msn.com> wrote:
]-This is a multi-part message in MIME format.
]-
]-
]-hi :o)
]-
]-I have to questions in Delhpi 1...
]-
]-1) is it possible to get the file size of a TEXTFILE, I know it can't be
]-done using FILESIZE, but is there any other way ??

yes, several ways, including using the FileSize function.
try one of these...

    o  use the FileSize function
          Var  f : file;
          assign(f, filename);
          reset(f, 1);
          SizeOfFile := FileSize(f);
          close(f);

    o  create a TFileStream object...
          fs := TFileStream.Create(filename, fmOpenRead + fmShareDenyNone);
          SizeOfFile := fs.size;
          fs.Free;

    o  use the FindFirst function; one of the fields in the
       TSearchRec variable passed to FindFirst will, on return,
       contain the file size
          if (FindFirst(filename, faAnyFile, MySearchRec) = 0) then
            SizeOfFile := MySearchRec.size

Mark Vaughan

]-
]-2) I am trying to launch and URL in windows 95, I am using the Shell
]-Execute command, so windows 95 looks at the file name to see what to open,
]-in this case the default web brouser, but it does not work !!!!
]-
]-I know I am using the fuction correct since it works perfect on TXT files,
]-Notepad is opened and the TXT file loaded, the same goes for MID files,
]-Media Player is opened and the MID file is loaded, but it does not work
]-with an URL or a DOC, in both cases I get error 8 "There was insufficient
]-memory to start the application.", why is this ?? and do you know a
]-solution
]-
]-if you can help me then please mail to Darkside_of_the_M...@MSN.COM
]-
]-Thank you very much
]-
]-Alex
]-
]-<html><head></head><BODY bgcolor="#FFFFFF"><p><font size=2 color="#000000" face="Arial">hi :o)<br><br>I have to questions in Delhpi 1...<br><br>1) is it possible to get the file size of a TEXTFILE, I know it can't be done using FILESIZE, but is there any other way ??<br><br>2) I am trying to launch and URL in windows 95, I am using the Shell Execute command, so windows 95 looks at the file name to see what to open, in this case the default web brouser, but it does not work !!!!<br><br>I know I am using
]-</font></body></html>
]-

Re:2 questions -FILESIZE & SHELLEXECUTE


Quote
Alex wrote:

> I have to questions in Delhpi 1...

> 1) is it possible to get the file size of a TEXTFILE, I know it can't
> be done using FILESIZE, but is there any other way ??

> Alex

I can answer part 1). Open the Textfile as FILE, then Filesize will
work,
but it will include the carriage returns and linefeeds.

HTH

Ray Cramer
R...@Pol.ac.uk

Other Threads