2016-04-07 37 views
0

我正在使用System.Windows.SplashScreen来显示启动画面。有一个奇怪的问题。如果图像位于不同的文件夹中,则应用程序会导致IO.IOException(未找到重新找回)。 我试过每种构建类型,并且图像具有完全相同的属性。SplashScreen导致IO.IOException

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); 
     } 
    } 
+0

像这样使用_splash = new System.Windows.SplashScreen(@“.. \ .. \ Images \ splash.jpg”); – rashfmnb

+1

发布您的文件夹结构。确保图像真的在该文件夹中。 –

+0

路径*不*指向现有图像的任何机会?为什么在应用程序文件夹外寻找一个Image文件夹? –

回答

0

添加您的图像资源文件,然后用它这link将有助于你这一点,你必须添加RESX文件到您的项目,然后使用它。

+0

我作为嵌入式资源添加到resource.resx。我也尝试过“编译时”的属性。但同样的错误发生。 – ChrisPlusPlus