You can find opensource code to for SecureFTP Server in the below said link
where the dlls can be used in .Net to access files in SecureFTP Server
http://www.tamirgal.com/blog/page/SharpSSH.aspx
Thanks to Tamir Gal
Note: In the wrapper class the rm function has to be called for remove file function in the source code and compile
Sunday, January 17, 2010
Tuesday, January 12, 2010
Error Log in Text File in Asp.Net 2.0
Simple vb.net code function used to log error in text file which rises in our application
This Code should be written in App_Code Folder of Web Application
This function can be called in all Exception Catches
To Err is Human
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Globalization
Public Class ErrorHandler
Public Shared Sub WriteError(ByVal errorMessage As String)
Try
Dim path As String = "~/Error/" & DateTime.Today.ToString("dd-mm-yy") & ".txt"
If (Not File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) Then
File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close()
End If
Using w As StreamWriter = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path))
w.WriteLine(Constants.vbCrLf & "Log Entry : ")
w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture))
Dim err As String = "Error in: " & System.Web.HttpContext.Current.Request.Url.ToString() & ". Error Message:" & errorMessage
w.WriteLine(err)
w.WriteLine("__________________________")
w.Flush()
w.Close()
End Using
Catch ex As Exception
End Try
End Sub
End Class
Imports System.IO
Imports System.Globalization
Public Class ErrorHandler
Public Shared Sub WriteError(ByVal errorMessage As String)
Try
Dim path As String = "~/Error/" & DateTime.Today.ToString("dd-mm-yy") & ".txt"
If (Not File.Exists(System.Web.HttpContext.Current.Server.MapPath(path))) Then
File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close()
End If
Using w As StreamWriter = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path))
w.WriteLine(Constants.vbCrLf & "Log Entry : ")
w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture))
Dim err As String = "Error in: " & System.Web.HttpContext.Current.Request.Url.ToString() & ". Error Message:" & errorMessage
w.WriteLine(err)
w.WriteLine("__________________________")
w.Flush()
w.Close()
End Using
Catch ex As Exception
End Try
End Sub
End Class
This Code should be written in App_Code Folder of Web Application
This function can be called in all Exception Catches
Try
'Your Code Goes Here’
Catch ex as Exception
ErrorHandler.WriteError(ex.Innerexception)
End Try
'Your Code Goes Here’
Catch ex as Exception
ErrorHandler.WriteError(ex.Innerexception)
End Try
To Err is Human
Subscribe to:
Posts (Atom)