Save file - xmlSerializer



I'm creating a method to serialize a file using this code:



public void Save(Object file, Type type, String path)
{
// Create a new Serializer
XmlSerializer serializer = new XmlSerializer(typeof(type));

// Create a new StreamWriter
StreamWriter writer = new StreamWriter(@path);

// Serialize the file
serializer.Serialize(writer, file);

// Close the writer
writer.Close();
}


But Visual Studio tells me this when I attempt to build: "Error 1 The type or namespace name 'type' could not be found (are you missing a using directive or an assembly reference?) c:\users\erik\documents\visual studio 2013\Projects\FileSerializer\FileSerializer\Class1.cs 16 65 FileSerializer "


Why is this?


Thanks! Erik


No comments:

Post a Comment