getsavefolderitem without getsavefolderitem

Hi everybody

Sorry, but im not get this on running

f = GetSaveFolderItem("*.csv", LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")
works

f = New folderitem(LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")
doesnt

My intention is just to save a csv WITHOUT any dialog

i fear i dont see the forest for the trees…

Thanks for hints

Christian

You should be able to do the following:

Dim f As FolderItem f = GetFolderItem(LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")

just tried it.

f still remains NIL…

i think it works for an existing item, but not for one to be created

What is “f” pointing to? How are you creating this file?

Are you writing a binary stream to the file after creating it?

Also, If you try the following:

dim pathstring as string = LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")

What does pathstring look like in the debugger? Maybe the lb. cell’s contain strings that the OS deems as unfit for a file name.

f is a folderitem in the same function
pathstring shows a syntaxerror

i dont think its the name - getsavefolderitem is working

[code] Dim sqlstring, line, pathstring As String
Dim rs As RecordSet

Dim f As FolderItem
Dim t As TextOutputStream

Dim d As New Date
d.SQLDateTime = getservertime // just an sqlselect(now)

sqlstring = “SELECT * FROM xojoleitfaden where leitfaden = '”+lb.Cell(lb.ListIndex, 5)+"’"
rs = db.SQLSelect(sqlstring)

if rs <> NIL AND rs.RecordCount > 0 then

collateFields rs // fieldnames

f  = GetSaveFolderItem("*.csv", LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")

//pathstring = LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")
//f  = new FolderItem(LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv")

if f <> NIL then
  
  t = TextOutputStream.Create(f) 
  line = createcsvHeader
  line = ConvertEncoding(line, Encodings.UTF8)
  t.WriteLine line
  
  while NOT rs.EOF
    
    line = createcsvDataline rs
    line = ConvertEncoding(line, Encodings.UTF8)
    t.WriteLine line
    
    rs.MoveNext
    
  Wend
  
end if

end if[/code]

How about the following:

f = GetFolderItem(LB.Cell(LB.ListIndex, 1)+"_"+LB.Cell(LB.ListIndex, 6)+d.SQLDateTime+".csv", folderitem.PathTypeNative)

yeeeaah - still another problem but its no longer a NIL object. Take a look at my precious folderitem

Macintosh HD:109_Ekornes2014-01-16 19/48/44.csv

Thanks to all of you

The “:” is an illegal character for OS X files. d.SQLDateTime has colons separating the time. You’ll want to strip those out.

ok i´ll do that. Another question: how can i crate / save it in a special folder und Mac AND Win

You might want to review the Files chapter in User Guide Book 3: Framework to get a better understanding of this.

Essentially, you create a FolderItem to point to the file wherever it may be. If you need separate locations for OS X/WIndows, then use #If TargetMacOS Or #If TargetWin32 to point the FolderItem appropriately for the platform on which it is running.

yes, i will :slight_smile:

Thanks for your help

Christian