0

我正在制作一个小型绘画程序,我希望用户能够将他们的创作保存到文件中。但是每当我尝试保存某些东西时,它都会导致“System.NullReferenceException”。另外,我如何让用户选择以什么格式保存?干杯。

用于保存的代码:

private void opslaan(object sender, EventArgs e)
{
    Schets schets;
    SaveFileDialog fileOpslaan = new SaveFileDialog();

    fileOpslaan.Title = "Bestand opslaan";
    fileOpslaan.AddExtension = true;
    fileOpslaan.Filter = "Bitmap Afbeelding (*.bmp)|*.bmp|JPEG Afbeelding (*.jpeg)|*.jpeg|GIF Afbeelding (*.gif)|*.gif|PNG Afbeelding (*.png)|*.png";

    if (fileOpslaan.ShowDialog() == DialogResult.OK)
        {
            schets.bitmap.Save(fileOpslaan.FileName);
        }
    }
4

1 回答 1

0
Schets schets = ... //Say here what your schets is, otherwise it's null.
于 2013-10-25T08:35:20.087 回答