简体   繁体   中英

SplashScreen causes IO.IOException

I am using System.Windows.SplashScreen to display a splash screen. There is a strange problem. If the image is in a different folder the application causes an IO.IOException (resurce not found). I tried every build-type and the images have the exact the same properties.

public class DinSplashScreen
{
    private const int SPLASH_SCREEN_FADING_OUT_DURATION = 1000;

    private System.Windows.SplashScreen _splash;

    public DinSplashScreen()
    {
        // this works
        _splash = new System.Windows.SplashScreen(@"splash.jpg")

        // this crashes
        _splash = new System.Windows.SplashScreen(@"..\Images\splash.jpg");
    }

    /// <summary>
    /// Shows the splash
    /// </summary>
    public void Show()
    {
        if(_splash != null)
        {
             // here the exception occurs
            _splash.Show(true, true);
        }
    }

将图像添加到资源文件中,然后使用它此链接将对您有所帮助,因为您必须将resx文件添加到项目中,然后使用它。

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