I'm working on an application that enables the user to modify the setting for a commercial application. The settings file for the comercial app shows to be a ANSI code page text file.
My application reads the file and populates a grid with its values. The user can then modify the values and save the file. The next time the commercial app runs it reads the modified setting file and executes accordingly. When the user of my application requests a save first a re-named copy of the original file is saved (the SaveMove routine does this) then the updated version of the file is created.
The issue I'm trying to resolve is that the file written by the routine below creates a UFT-8 txt file not an ANSI one. I read that by default .Net uses UTF-8 but I have not been able to determine how to make it write it in ANSI. I've tried changing the encoding when creating the file but it still gets written in UTF-8 Below is the routine that is called to write the file.
Can one of you tell me what I need to do to create an ANSI based text file and possibly explain the differance between code set and encoding in this context?
Public Function WriteMethod() As Boolean
Dim success As Boolean = False
Dim fi As New FileInfo(File)
If fi.Exists Then SaveMove(fi) 'just to play save
'The first version of this line had no encoding specified so .net used UFT-8
'I tried both of the following lines with the same result.
Dim inifile As New System.IO.StreamWriter(File, False, System.Text.Encoding.Unicode)
'Dim inifile As New System.IO.StreamWriter(File, False, System.Text.Encoding.ASCII)
Dim nrs As Int32() = m_Meth.GetAllStepNr()
For Each n As Int32 In nrs
inifile.WriteLine("[Step" & n.ToString() & "]")
Dim hcs As HetCatStep = m_Meth.GetStepOf(n)
success = True
Catch ex As Exception