Jacob Bahula

Jacob Bahula

  • NA
  • 12
  • 16.6k

xmltextwriter

Jul 25 2007 8:16 AM
Hi am trying to use xmltextwriter to create new file but tells me that "Empty path name is not legal."
here is my code

public void SaveXmlDocument(SaveType type)

{

string newFileName = this.fileName;

SaveFileDialog saveFileDialog1 = new SaveFileDialog();

saveFileDialog1.Filter = fileDlgFilter;

if ((type == SaveType.SaveAs) ||

Empty(newFileName))

{

if (!Empty(newFileName))

{

saveFileDialog1.InitialDirectory = Path.GetDirectoryName(newFileName);

saveFileDialog1.FileName = Path.GetFileName(newFileName);

}

else

{

saveFileDialog1.InitialDirectory = fileDlgInitDir;

saveFileDialog1.FileName = newDocName;

}

DialogResult res = saveFileDialog1.ShowDialog(frmOwner);

if (res != DialogResult.OK)

// return false;

newFileName = saveFileDialog1.FileName;

//fileDlgInitDir = new FileInfo(newFileName).DirectoryName;

}

XmlSerializer mySerializer = new XmlSerializer(typeof(DocManager));

// XmlTextWriter myWriter = textwri

FileStream myStream = new FileStream(newFileName,FileMode.Create, FileAccess.Write,FileShare.Read);

XmlTextWriter myWriter = new XmlTextWriter(myStream,Encoding.UTF8);

//myWriter = Formatting.Indented;

mySerializer.Serialize(myStream,type);

myStream.Close();


Answers (1)