Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: size of a file?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Colombia
    Posts
    1,870

    Default size of a file?

    Hi all

    I have been looking for how to read the size of a file?
    I need to read what is the size to determine if I can send it via email or not.
    I can't find in the help how to know the size of a file. Does anyone know the instruction?

    Edgar

  2. #2
    Join Date
    Mar 2009
    Location
    Brasil
    Posts
    25

    Default Re: size of a file?

    Hi, Edgar
    Would it be the mlistFiles function? I've been using it for a long time ... I hope it serves you, in this example it loads a grid with the information.

    Procedure mListFiles String sFilePath
    Local String sWin32FindData sDiretorio sCompila sLinha
    Local String sShortFileName sLongFileName sViewSrcPac sLePrjPac
    Local Pointer lpsFilePath lpsWin32FindData
    Local Handle hFindFile
    Local Dword dwFileAttributes dwFileSizeHigh dwFileSizeLow
    Local Dword dwLowDateTime dwHighDateTime
    Local Dword dwLowDateTime1 dwHighDateTime1
    Local Dword dwLowDateTime2 dwHighDateTime2
    Local Integer iVoid iRetval iTam iArq iStTecla iItem iExiste


    if ((trim(sFilePath)) = "0") procedure_return
    GetAddress Of sFilePath To lpsFilePath
    Move 0 to iItem


    move (length(sFilePath)) to iTam
    move (mid(sFilePath,(iTam -6),3)) to sDiretorio


    ZeroType Win32_Find_Data To sWin32FindData
    GetAddress Of sWin32FindData To lpsWin32FindData


    Move (FindFirstFile (lpsFilePath, lpsWin32FindData)) To hFindFile
    If hFindFile Ne INVALID_HANDLE_VALUE Begin
    Repeat
    Move (GetAsyncKeyState(VK_ESCAPE)) to iStTecla
    if iStTecla Get YesNo_Box "Cancela ? " to iRetval
    if (MBR_NO=iRetVal) procedure_return


    GetBuff_String From sWin32FindData At Win32_Find_Data.cFileName To sLongFileName


    GetBuff_String From sWin32FindData At Win32_Find_Data.cAlternateFileName To sShortFileName
    GetBuff From sWin32FindData At Win32_Find_Data.nFileSizeHigh To dwFileSizeHigh
    GetBuff From sWin32FindData At Win32_Find_Data.nFileSizeLow To dwFileSizeLow


    GetBuff From sWin32FindData At Win32_Find_Data.ftCreationLowDateTime To dwLowDateTime
    GetBuff From sWin32FindData At Win32_Find_Data.ftCreationHighDateTime To dwHighDateTime


    GetBuff From sWin32FindData At Win32_Find_Data.ftLastAccessLowDateTime To dwLowDateTime1
    GetBuff From sWin32FindData At Win32_Find_Data.ftLastAccessHighDateTime To dwHighDateTime1


    GetBuff From sWin32FindData At Win32_Find_Data.ftLastWriteLowDateTime To dwLowDateTime2
    GetBuff From sWin32FindData At Win32_Find_Data.ftLastWriteHighDateTime To dwHighDateTime2


    Moveint (FindNextFile (hFindFile, lpsWin32FindData)) To iRetval


    Move (uppercase(sFilePath)) to sViewSrcPac
    replace "*.XLS" in sViewSrcPac with ""
    append sViewSrcPac (Uppercase(Trim(sLongFileName)))
    move (Trim(sViewSrcPac)) to sLePrjPac
    replace "*.xls" in sViewSrcPac with ""


    file_exist sViewSrcPac iExiste
    if (iExiste = 0) move "." to sLongFileName
    if ((trim(sLongFileName)) <> ".") begin
    if ((trim(sLongFileName)) <> "..") begin
    Send Add_Item to (oGrid(listagem(Self))) 0 (uppercase(sLongFileName)) // nome
    set Entry_State of (oGrid(Listagem(self))) item (iItem + 0) to False
    Send Add_Item to (oGrid(listagem(Self))) 0 (ConvertDateTime (dwLowDateTime, dwHighDateTime)) // data
    set Entry_State of (oGrid(Listagem(self))) item (iItem + 1) to False
    Send Add_Item to (oGrid(Listagem(Self))) 0 ((dwFileSizeHigh * MaxDword) + dwFileSizeLow) // tamanho
    set Entry_State of (oGrid(Listagem(self))) item (iItem + 2) to False
    Send Add_Item to (oGrid(Listagem(Self))) 2 "" //checkbox
    Set Checkbox_Item_State of (oGrid(Listagem(self))) Item (iItem + 3) To True
    calc (iItem + 4) to iItem
    increment iArq
    end
    end
    Until iRetval Eq Dffalse
    Moveint (FindClose (hFindFile)) To iVoid
    End
    End_Procedure

  3. #3
    Join Date
    Feb 2009
    Location
    Boxtel, The Netherlands
    Posts
    1,009

    Default Re: size of a file?

    Hi Edgar,

    Take a look at 'Get_Channel_Position'.
    Kind regards,

    Hans van de Laar
    Data Access Europe

  4. #4
    Join Date
    Feb 2009
    Location
    Colombia
    Posts
    1,870

    Default Re: size of a file?

    Pacorbett/Hans:

    The idea is to read the size at runtime and if it does not exceed 12K, send it via email. You know that files over 10K cannot be attached to an email.

    Edgar

  5. #5
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    10,150

    Default Re: size of a file?

    I regularly send much larger files than that - several hundred KB at least - sometimes a MB.

    Maybe it's different in Columbia than it is in the US?
    Garret

    What if UFOs are just billionaires from other planets?

  6. #6
    Join Date
    Mar 2009
    Location
    Brasil
    Posts
    25

    Default Re: size of a file?

    Quote Originally Posted by Garret Mott View Post
    I regularly send much larger files than that - several hundred KB at least - sometimes a MB.

    Maybe it's different in Columbia than it is in the US?
    Hi, I also use it with much bigger sizes. Is there any restriction there? The function that Mike Peat sent seems much more practical and simple.

  7. #7
    Join Date
    Feb 2009
    Location
    Colombia
    Posts
    1,870

    Default Re: size of a file?

    Pacobett:

    Your code is also very timely and will also have a trade in my programs.
    God bless you.

    Edgar

  8. #8
    Join Date
    Mar 2009
    Location
    Brasil
    Posts
    25

    Default Re: size of a file?

    Amem, you too.

  9. #9
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    10,150

    Default Re: size of a file?

    I generally limit to 1MB. Sometimes bigger works, sometimes not.
    Garret

    What if UFOs are just billionaires from other planets?

  10. #10
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    3,571

    Default Re: size of a file?

    Rules like that are implemented at email’s server level. Your sending server should bot restrict it, but the receiving server could.

    This is totally out of your control. And rules may change over time. So be careful
    Samuel Pizarro

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •