我在图片中遇到了问题,我为我的应用程序创建了一个名为gridBg.png的背景,并以这样的方式阅读了它:
string currentDir = Directory.GetCurrentDirectory();
if (File.Exists((currentDir + @"/Images/gridBg.png")))
{
bgAnimated.StopAnimation();
bgAnimated.GifSource = currentDir + @"/Images/gridBg.png";
bgAnimated.NormalLoopFrameCount = 20;
bgAnimated.SpecialLoopFrameCount = 20;
bgAnimated.TotalLoopFrameCount = 40;
bgAnimated.NormalLoopRepeatCount = 1;
bgAnimated.SpecialLoopRepeatCount = 1;
bgAnimated.StartAnimation();
}在调试模式下,它全部正常工作。我在安装项目中添加了图像,并给出了图像路径。当我安装和尝试应用程序时,它也正常工作,但问题是,我的一些朋友没有看到图像,而是图像在正确的位置,图像文件夹。有人建议过吗?
已解决的字符串: string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
发布于 2013-07-10 18:38:36
我甚至可以认为发生这种情况的唯一方法是,您的朋友的Working Directory没有设置为安装目录。这将导致currentDir出错。
根据MSDN文档,GetCurrentDirectory这样做:
获取应用程序的当前工作目录。
https://stackoverflow.com/questions/17578371
复制相似问题