iOS Question File.IsDirectory function is missing in IOS?

Discussion in 'iOS Questions' started by little3399, Jun 2, 2015.

  1. little3399

    little3399 Active Member Licensed User

    HI,

    It seem to the File.IsDirectory function was missing in B4I ? Is there a same method should be using ?

    Tks!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It will be added in the next update. For now you can use this code:
    Code:
    Sub IsDirectory(Dir As String, FileName As StringAs Boolean
       
    Dim filetype As String = File.GetAttributes(Dir, FileName).Get("NSFileType")
       
    Return filetype = "NSFileTypeDirectory"
    End Sub
     
  3. little3399

    little3399 Active Member Licensed User

    HI, Erel

    I using your code , but it show error ... and I had upload the program source code for you ...

    Tks!
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    Note that you can right click on the logs to copy them. It is better than a screenshot.

    I guess that there is no such file or directory. You can check it with File.Exists before you call IsDirectory.
     
  5. little3399

    little3399 Active Member Licensed User

    Error getting attributes: Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x170268400 {NSFilePath=/var/mobile/Containers/Data/Application/D694812A-9867-438B-8A4D-13BA5FE25CC2/Documents/B4iDir, NSUnderlyingError=0x170058720 "The operation couldn’t be completed. No such file or directory"}
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    My assumption was correct. You need to use File.Exists before you can check whether the entry is a file or a folder.
     
Loading...