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 ModuleExample:
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
- Author: Massimo Da Frassini
- Submitted on: 1-12-2009 23:02:57
- Language: VB
- Type: System.String
- Views: 3629
Double click on the code to select all.