[Mono-bugs] [Bug 74513][Nor] New - mono 1.1 will append chars <feff> before first message whenever the file is opened for append.
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 8 Apr 2005 08:49:03 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by gshaily@novell.com.
http://bugzilla.ximian.com/show_bug.cgi?id=74513
--- shadow/74513 2005-04-08 08:49:03.000000000 -0400
+++ shadow/74513.tmp.28917 2005-04-08 08:49:03.000000000 -0400
@@ -0,0 +1,153 @@
+Bug#: 74513
+Product: Mono: Class Libraries
+Version: 1.1
+OS: SUSE 9.1
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gshaily@novell.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mono 1.1 will append chars <feff> before first message whenever the file is opened for append.
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+When mono creates a fresh file and write into it, it does not append <feff>
+character in beginning of line but if the file is already present and it is
+appending messages into it then while opening the file it appends <feff>
+char at beginning.
+
+mono 1.1 will append chars <feff> before first message whenever the file is
+opened for append.
+
+
+Steps to reproduce the problem:
+1. Compile the following code
+using System;
+using System.IO;
+
+namespace FileOpen
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ private FileStream log = null;
+ private StreamWriter logWriter = null;
+
+ private string fileName = "test.log";
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+ new Class1();
+ }
+
+ Class1()
+ {
+ OpenFile();
+ Log("This is test message");
+ }
+ private void CreateFile()
+ {
+ if (File.Exists(fileName))
+ return ;
+
+ try
+ {
+ // Creation of file if it does not exist
+ FileStream fs = new FileStream(fileName, FileMode.CreateNew,
+FileAccess.Write, FileShare.ReadWrite);
+ fs.Close();
+ }
+ catch (Exception ex)
+ {
+ // Handle 2 processes having tried to create the file at the same time.
+ if (File.Exists(fileName))
+ {
+ return;
+ }
+ else
+ {
+ Console.WriteLine(": Not able to create the file: " + fileName);
+ }
+ }
+ }
+
+ // File will be opened as soon as the Simple File Appender is configured
+ private void OpenFile()
+ {
+
+ try
+ {
+ CreateFile();
+ log = File.Open(fileName, FileMode.Append, FileAccess.Write,
+FileShare.ReadWrite);
+ logWriter = new StreamWriter(log, System.Text.Encoding.Default);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine( ": cannot open a file < " + fileName + ">" +
+ex.Message + ":" + ex.StackTrace);
+ }
+
+ }
+
+ // Logging the message in File
+ private void Log(String logMessage)
+ {
+ try
+ {
+ if (logWriter != null)
+ {
+ log.Seek(0, SeekOrigin.End);
+ logWriter.WriteLine(logMessage);
+ logWriter.Flush();
+ }
+ }
+ catch (IOException ex)
+ {
+ Console.WriteLine(": Unable to write to Localfile" + ex.Message + ":" +
+ex.StackTrace);
+ }
+ }
+
+
+
+ }
+}
+
+2. Run the boave code
+3. Behaviour: When it creates a fresh file and write into it, it does not
+append <feff> character in beginning of line but if the file is already
+present and it is appending messages into it then while opening the file it
+appends <feff> char at beginning.
+
+
+Actual Results: When it creates a fresh file and write into it, it does not
+append <feff> character in beginning of line but if the file is already
+present and it is appending messages into it then while opening the file it
+appends <feff> char at beginning.
+
+
+
+Expected Results: It should not append<feff> chars whenever the file is opened
+
+
+How often does this happen?
+
+
+Additional Information:
+I found that similar problems are faced by other developers too. There is
+an archive on internet regarding this
+http://archive.neotonic.com/archive/mono-list/messages/8843?noheader=1