简体   繁体   中英

C# OpenFileDialog Empty

I am trying to get a messagebox if my picturebox is empty.

if (dial == DialogResult.Yes)
{
    if (openfile.FileName == string.Empty)
    {
        MessageBox.Show("Please Upload Poster");
    }
    else
    {
        this.Close();
        poster = openfile.FileName;
    }

}
if (pictureBox1.Image != null)
{
    Common.MessageBoxUtilities.WarningMessageBox("You Have Image");
}
else if (pictureBox1.Image == null)
{
    Common.MessageBoxUtilities.WarningMessageBox("You Dont Have Image");
}

Try something like this?

source: http://www.codeproject.com/Questions/677961/How-To-Check-PictureBox-Control-has-image-or-not

try it this way:

 if(myPictureBox.Image == NULL)
{
    //MessageBox
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM