tlhintoq: thanks for your 2 cents... Well I spent a few hours reading about delegates and events... but I don't see, in practice, how I can use them in my example explained in the post :-( or... it seems very complicated.
If I've understood your post you suggest me to create a MethodStarted event. Seems a good idea, but then... should I create also a MethodStopped event?
I will check again some events tutorials and see...
User Profile
Collapse
-
method with method name as parameter
Hello,
as "exercise" (I needed it) I've built a simple logging/tracing classLibrary and I'm using it to write in a txt what my application is doing, and save the exceptions.
I'm not an expert programmer and I want to improve my library. Actually to trace something I have to do like this:
...Code:Logger log = new Logger(); SomeMehod(); log.Trace("I usually write a comment here, such as: So -
In your case, your default windows encoding is ASCII, probably because you are from the US (no accented letters). In Switzerland (where I come from) or Germany it's ANSI 1250.
Did you try to save this as ASCII? "éàèüöä" (I guess you can't, you have to save it as UTF8)Leave a comment:
-
Coool I found the solution!!! My initial code was not so wrong.
What was wrong is that I can't specify the encode in the streamwriter Write() method, but it's possible to specify it when you instantiate the StreamWriter object! So definitively the key to the problem was to write the file with the correct encoding, with streamwriter. No need to convert it before, if you do not specify the encoding, streamwriter writes it anyway in UTF8....Leave a comment:
-
corrections
By the way, my previous code is wrong... It doesnt seem possible to tell Streamwriter which encoding to use... so, I tried like this, but still no success:
...Code:string filePath = "c:\\test.txt"; StreamReader fileStream = new StreamReader(filePath); string fileContent = fileStream.ReadToEnd(); Encoding fileEncoding = fileStream.CurrentEncoding; fileStream.Close();
Leave a comment:
-
I need ANSI, because a third party application can read only ANSI encoded. I've already tried with ASCII, but it doesn't work (ascii converts accented letters in "?")...
I tried also with GetEncoding(125 0) or other code types, no way...Leave a comment:
-
how to convert UTF8 file into ANSI?
Hello there, I am dealing with files encoded in UTF8 and I can't find a way to convert them into ANSI.
I've already searched in google for this since a while, and I'm not achieving the result I want to achieve if I use the code I've found on the web, which is the following:
Example of test.txt (save it as UTF8): "éàèüöä"
...Code:string filePath = "c:\\test.txt"; StreamReader fileStream
No activity results to display
Show More
Leave a comment: