vb.net - StreamWriter text file gets created but contains no lines -


i'm trying write text lines little log file in windows form application , cannot see why no lines written. file gets created ok , of following executes without error when open new file notepad, there no lines. key snippets follow:

    dim sfilename = app_path() & "\logs\" & sjobname & ".log"     try         using fs filestream = new filestream(sfilename, filemode.append, fileaccess.write)             using w streamwriter = new streamwriter(fs)                 dim s string = "beginning execution (jobname=" & sjobname & ")"                 log(s, w)                 s = "connection in effect: " & buildconnectstring()                 log(s, w)                 dim loader new importer                 loader.loaddata(me.txtfn.text, w)             end using         end using     catch ex exception         msgbox(ex.message)     end try  public sub log(logmessage string, w streamwriter)     w.writeline("{0} {1}: {2}", datetime.now.tolongtimestring(), _         datetime.now.toshortdatestring(), logmessage) end sub 

and i'm trying write log different class has been passed streamwriter parameter:

public function loaddata(byref filename string, _                          byref w streamwriter) string     dim s string = "test logging loader class"     mainform.log(s, w) 

in little test, expecting see 3 lines i'm getting nothing. cannot see doing wrong.

it works me, if code doesn't work you, can use code ...

private sub button1_click(sender object, e eventargs) handles button1.click     dim sfilename = app_path() & "\logs\" & sjobname & ".log"     try         dim s string = "beginning execution (jobname=" & sjobname & ")"         log(s, sfilename)         s = "connection in effect: " & buildconnectstring()         log(s, sfilename)         dim loader new importer         loader.loaddata(me.txtfn.text, sfilename)     catch ex exception         msgbox(ex.message)     end try end sub  public sub log(logmessage string, strpath string)     io.file.appendalltext(strpath, string.format("{0} {1}: {2}", datetime.now.tolongtimestring(), datetime.now.toshortdatestring(), logmessage) + vbcrlf) end sub  public function loaddata(byref filename string, _                      strpath string) string     dim s string = "test logging loader class"     log(s, strpath) end function 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -