File Types question

  1. 5 weeks ago
    Edited 5 weeks ago

    So struggling with file Types, here's my situation:

    I need my app to read(and write) a file - its "just text" but has a specific extension .nka

    Whats the best way to set this up to work? I've tried to define a new file type, based upon the common file types but it doesnt seem to work. Will its .Exists is false.

    Perhaps I'm over complicating this, all I want to do is open a text file called "config.nka" for reading and writing, whats the simplest way to do this?

    Hmm, now I get 0 (zero) error code on this, what am I doing wrong?

    Dim InText as FolderItem
    InText = New FolderItem("config.nka")
    if InText <> Nil Then
      if InText.Exists Then
        MsgBox("got it!!!")
      Else
        MsgBox(Str(InText.LastErrorCode))
      End if
    Else
      MsgBox("fail all over")
    End if

    More searching here reveals

    On Windows, when you run from the IDE, the project is built in a new subfolder, so your file won't be next to the program. Try

    #if DebugBuild
    f = getFolderItem("").Parent.Child("svi.nan")
    #else
    f = getFolderItem("svi.nan")
    #endif

    ..so answered my own question. Thanks anyway..

  2. Dave S

    Nov 6 San Diego, California USA

    What are you expecting to happen in your first code snippet?
    ALL it does it assign a FOLDERITEM....
    If you are expecting it to read or write a file, then you need more code to do that
    A BinaryStream or TextStreamIinput or TextStreamOutput object as well

  3. I was expecting it to not return Nil, which is what it was doing, but as you may see from further on its because I was looking for an existing file (config.nka) in the wrong place - I was running the debugger...so needed to set the path for compiled and debugging scenarios...

or Sign Up to reply!