SaveToFile

Imports System.Runtime.CompilerServices

Module m_Extensions
<Extension()> Public Function SaveToFile(ByVal Expression As String, ByVal Filename As String) As Exception
        Try
            Dim SW As New System.IO.StreamWriter(Filename, False, System.Text.Encoding.Default)
            SW.Write(Expression)
            SW.Flush()
            SW.Close()
            Return Nothing
        Catch ex As Exception
            Return ex
        End Try
    End Function
End Module
Example:
Dim Text as string = "Example for 'SaveToFile' Extension"

Dim E As Exception = Text.SaveToFile("c:\data.txt")
If E IsNot Nothing Then
   MessageBox.Show(E.ToString)
End If

Description

This Extension Method saves string content to a file

Details

Double click on the code to select all.

 

;