2

I am storing the string array content into a txt file and then trying to change the extension of the txt file to xml so as to make it read using XDocument.

Now the problem is that when I am trying to change the extension using the Path.ChangeExtension method, it isn't changing the extension.

I have a task of sending data using WCF by only using string messages and I want to send an XML file. So I am dumping the XML file content into a string array and sending it over to the client. But my client is only able to read from XML file and that is the reason that I am trying to convert the string array into an XML file.

Also, the XML's structure is always going to be the same in every communication and of course only the data is going to change.

Please help me figure out how I can implement this.

4

1 回答 1

1

Path.ChangeExtension()方法只产生一个字符串,它不会改变磁盘上的任何东西。

使用结果File.Rename

string newFilename = Path.ChangeExtension (oldFilename , ".xml");
File.Move(oldFilename , newFilename );
于 2013-11-12T19:24:31.187 回答