Skip to content

Write 15 lines above and below from where the exception

suhas setty

Asked Jun 29, 2015, 2:19 AM EDT1 answer
Share
LinkedInX
Hi ,
 
i am reading the log file,if i found exception from that particular line i have to write 15 lines from that exception line to text file.
 
Example:
 
a
b
b
bgggfgf
sdffs
dfsadfds
adsfdsaf
dsfsdafs
adasdas
sadasdsadas
as
dasdsadsad

adasdsada

sdasdsad
sdsadasdsadas
sdasdsadasd
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
dadasdsad
sdasdsads
System.Reflection.ReflectionTypeLoadException:
sadasdasdasd
dasdasdsad
 
Now i got exception at line no 19  so now i have to copy above 15 lines and below 15 lines.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • madhuri Gamane
    0
    why you want to copy above 15 lines and below 15 lines ??
    it means you don't want the exception in your file ??
    Code
    if i am correct, use try...catch block and don't  catch message
    ex..
    Try
       {
          // Do Something
       }
    Catch
       {
          // don't catch exception just leave it, as it is
       }
    
    If it will help, Please accept the solution
    0