Why doesn't my StreamWriter work outside the IDE?

blackduck603

Member
Joined
Sep 17, 2008
Messages
21
Location
NH
Programming Experience
3-5
I recently added a Streamwriter for logging certain runtime activities while my windows application is running. This is a windows Form application developed in Visual Studio .NET 2003. The Streamwriter logging works fine when I am running in DEBUG mode via the Visual Studio IDE. However, when I run my executable in its runtime folder (C:\Pgm files\my pgm\test\) the output log file does not get created or written to. I have tried creating a copy of the file in the target C:\Tmp folder, but it still doesn't work.

NOTE: I believe that this has something to do with where my EXE is executing from (No error via IDE with EXE running in my project folder, error occurs when in pgm files folder), but I just can't seem to get my mind around this today.

:)

VB.NET:
..... some module in my application
LogIt("User deleted record: " & nRecordID.ToString())


       Public Sub LogIt(ByVal sMsg) 
            Dim fi As New FileInfo("C:\Tmp\MyLog.txt")    
            Dim sw As StreamWriter    
            If Not fi.Exists() Then       
                sw = fi.CreateText()       
            Else      
                sw = fi.AppendText()     
            End If       

            sw.WriteLine(System.DateTime.Now.ToString() & " - " & sMsg)     
            sw.Flush()
            sw.Close()    

      End Sub

I know this is going to be something stupid.
What am I missing here?

NEVERMIND
I figured it out.
I forgot to copy my most recent DLL to the run-time folder.
DUH
 
Last edited:
Back
Top