I currently have the code below in my WPF application which does exactly what I want it to do, however, upon publishing this it won't necessarily be able to access these folder locations as they won't be pointing to the correct directory nor will the folders exist.
I was hoping somebody might be able to tell me what is the best way to save something into a local folder?
Whether it's inside the application folder itself or not is of no issue either.
The code I'm currently using for the writing of the file:
using (Stream stream = File.Open(@"....Templatesdata.bin", FileMode.Create))
{
BinaryFormatter bin = new BinaryFormatter();
bin.Serialize(stream, templateList);
}
The code I'm currently using for the loading of the file:
using (Stream stream = File.Open(@"....Templatesdata.bin", FileMode.Open))
{
BinaryFormatter bin = new BinaryFormatter();
templateList = (List<Template>)bin.Deserialize(stream);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…