FilesEx library - returns file information

Discussion in 'Additional Libraries' started by agraham, Feb 26, 2008.

  1. agraham

    agraham Expert Licensed User

    This small library lets you get the attributes and dates and times associated with a file or directory as both strings and numbers. It also lets you find all the directories or files within a directory. Help file included in zip. Should work on both desktop and device under .NET 1.0/1.1 and later.

    If anyone can think of any more file and directory stuff that is not presently available in B4PPC then please post the suggestion here.

    EDIT :- Version 1.1 with FileMove and FileRename added.

    EDIT :- Version 1.2 with DirectoryCopy, DirectoryCopytree, DirectoryMoveTree and DirectoryRename added

    EDIT :- Zip version 1.2a reposted with corrected Help file. The dll is unchanged.

    EDIT :- Source code for dll merging posted. Put it in the Basic4ppc Desktop\Libraries folder.

    EDIT :- Version 1.3 posted with source for merging. See post #14

    EDIT :- Version 1.4 posted. See post #17
     

    Attached Files:

    Last edited: Apr 18, 2010
  2. francisco cobos

    francisco cobos Member Licensed User

    Very useful work!,

    Is there any possibility of change some characteristic of the file (I'm would like to change de name of the files, for example)?
     
  3. agraham

    agraham Expert Licensed User

    Version 1.1 posted with FileMove and FileRename added. In fact, somewhat surprisingly, there is no direct file rename ability available in .NET - it has to be done by moving a file - i.e copy and delete, so it could be done that way in B4PPC. However I have provided these two functions anyway!

    FileRename is in fact a FileMove using the path of the original file as the path of the new file.
     
  4. francisco cobos

    francisco cobos Member Licensed User

    Thank you very much for your ideas, they are getting Basic4pp more and more interesting!
     
  5. Hennell

    Hennell Member Licensed User

    This is awesome, just what I need. Thanks!
     
  6. francisco cobos

    francisco cobos Member Licensed User

    any possibility of copy or move a directory with the subdirectories inside?

    I use a lot Basic4 in the desktop version, but I miss some features of VB like "Dircopy"

    Thanks in advance!
     
  7. agraham

    agraham Expert Licensed User

    See first post for new version. I've tested it but use it at your own risk. DirectorytMoveTree may bend your head a little - it did mine! The top level item moved is NOT the directory, it is all the files in the directory and they must go into a new directory that didn't exist before. This new directory can be made in an existing directory. This behaviour is determined by .NET.
     
  8. francisco cobos

    francisco cobos Member Licensed User

    Thanks very much Agrahan, till I have proved, it works fine!
     
  9. francisco cobos

    francisco cobos Member Licensed User

    Hi Agrahan, I've tried to use the "DirectoryTicksInfo" method as you explain in the help file, but this not appears as an option after the "FilesEx1."
    I'm afraid it is too difficult for me to know if this is a bug or is something tha I have missed...
    Thanks anyway!
     
  10. agraham

    agraham Expert Licensed User

    Sorry, my fault. I renamed it but didn't correct the help. It is called DirectoryDoubleInfo and there is a counterpart for files, FileDoubleInfo. A corrected help file is now posted in a new zip in post #1 of this thread.
     
  11. agraham

    agraham Expert Licensed User

    Source code for dll merging posted in original post.
     
  12. mjcoon

    mjcoon Well-Known Member Licensed User

    Hi, is there a file browser control for picking a file from filestore?

    (Sounds like a fairly universal need, from other environments!)

    Mike.
     
  13. agraham

    agraham Expert Licensed User

    Check out Help->Main Help->Controls->OpenDialog
     
  14. agraham

    agraham Expert Licensed User

    Version 1.3 posted with FileSetAttribute and FileGetAttribute added to manipulate file attributes. The Bitwise library will be useful for this.
     
  15. tsteward

    tsteward Active Member Licensed User

    I have a little problem, probably my misunderstanding.

    My Code
    Code:
    data()=filesex1.DirectoryStringInfo(MyDir)
    CreatedTB.Text=data(
    1)
    EditedTB.Text=Data(
    3)
    The above code produces no errors but the created date and the last edited date are both the same.

    I am using windows mobile 6.1 if that make any difference.
    Using Resco Explorer it shows the creation date but no other dates.

    Also is there a way to get the size of the directory and all sub directories?
     
  16. agraham

    agraham Expert Licensed User

    I'm a bit too busy to knock up a test app on my device but that doesn't seem unreasonable to me as the dates refer to the directory entry itself, not necessarily when the contents change. On the desktop, NTFS file system, the last accessed and last edited dates for a directory are always the same presumably because NTFS log file activity - the devices simpler file system doesn't.

    I'm afraid not.
     
  17. agraham

    agraham Expert Licensed User

    Version 1.4 has a new method, SpecialPath, that returns the full path for some special folders. Unlike GetSpecialPath in the Hardware library this works on both desktop and device.
     
  18. mjcoon

    mjcoon Well-Known Member Licensed User

    Is it, or could it be, possible to extract the 8.3 version of a filename for a file that has a longer name? I can do it with the Dir DOS command but can it be done within Basic4PPC?

    My usage would be to run DOS programs that do not understand long filenames by getting the 8.3 version to pass via Shell() or Process().

    Mike.
     
  19. agraham

    agraham Expert Licensed User

    You have to call a Win32 API to get a short name. I can see no way of doing it in .NET, understandably as it is only a legacy requirement. Perhaps you could convert it yourself using the alogorithm described here 8.3 filename - Wikipedia, the free encyclopedia
     
  20. mjcoon

    mjcoon Well-Known Member Licensed User

    Thanks for that reference, Andrew.

    As I suspected, features like "(or "TEXTFI~2.TXT", should "TEXTFI~1.TXT" already exist)" and "digits derived from an undocumented hash of the filename" make it impossible to work out a shortname post-hoc, so I'll have to abandon this scenario.

    Mike.
     
Loading...