last insert ID of drupal_write_record I need to get the latest inserted id, this is the line im using for writing files to my db    

drupal_write_record('file_managed', $file, 'fid');


any ideas?
I found the answer myself. Use $file-&gt;fid.