C# Programming
06-14-2009, 02:53 PM
Hi
i have a class called testparams:
[Serializable()]
public class TestParams {
public TestParams() {
}
private string m_filename;
[EditorAttribute(typeof(FileNameEditor), typeof(UITypeEditor))]
public string FileName {
get { return m_filename; }
set { m_filename = value; }
}
}
i use propertygrid and select the object :
TestParams TP = new TestParams();
propertygrid.SelectedObject = TP;
serialization :
private void Save(TestParams obj) {
XmlSerializer xs = new XmlSerializer(typeof(TestParams));
using (FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\testparams.xml", FileMode.OpenOrCreate)) {
xs.Serialize(fs, obj);
}
}
}
The problem:
if the user selects the file with the "..." button and i try to serialize TP to xml nothing get written in the file !
when user writes his text freely the xml file is written correctly .
any help will be appreciated
shay
modified on Sunday, June 14, 2009 6:28 AM
i have a class called testparams:
[Serializable()]
public class TestParams {
public TestParams() {
}
private string m_filename;
[EditorAttribute(typeof(FileNameEditor), typeof(UITypeEditor))]
public string FileName {
get { return m_filename; }
set { m_filename = value; }
}
}
i use propertygrid and select the object :
TestParams TP = new TestParams();
propertygrid.SelectedObject = TP;
serialization :
private void Save(TestParams obj) {
XmlSerializer xs = new XmlSerializer(typeof(TestParams));
using (FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\testparams.xml", FileMode.OpenOrCreate)) {
xs.Serialize(fs, obj);
}
}
}
The problem:
if the user selects the file with the "..." button and i try to serialize TP to xml nothing get written in the file !
when user writes his text freely the xml file is written correctly .
any help will be appreciated
shay
modified on Sunday, June 14, 2009 6:28 AM