Προσπαθώ να γράψω ένα αρχείο από Windows Application το οποίο να γράφει ένα αρχείο όπου επιλέξει ο χρήστης
public static void SaveFileDialog(string text){
text = "Test Now Function Ελληνικά δοκιμή";//δοκιμαστικά
SaveFileDialog DialogSave = new SaveFileDialog();
DialogSave.DefaultExt = "txt";
DialogSave.Filter = "Text file (*.txt)|*.txt|XML file (*.xml)|*.xml|All files (*.*)|*.*";
DialogSave.AddExtension = true;
DialogSave.RestoreDirectory = true;
DialogSave.Title = "Where do you want to save the file?";
DialogSave.InitialDirectory = @"C:/";
if (DialogSave.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("You selected the file: " + DialogSave.FileName);
//Stream myStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(text));
MemoryStream myStream = new MemoryStream(System.Text.Encoding.Default.GetBytes(text));
if ((myStream. = DialogSave.OpenFile()) != null)
{
myStream.Close();
}
}
else {
MessageBox.Show("You hit cancel or closed the dialog.");
}
DialogSave.Dispose();
DialogSave = null;
}
Στην τελευταία μου προσπάθεια θεωρεί ότι myStream. = DialogSave.OpenFile() προκαλεί
error CS0266: Cannot implicitly convert type 'System.IO.Stream' to 'System.IO.MemoryStream'. An explicit conversion exists (are you missing a cast?)
Καμιά ιδέα γιατί ψάχνοντας δεν βρήκα κάτι που να εξηγεί ποιο stream χρησιμοποιούμε για να το γράψουμε με την Savve FileDialog