首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BackGround的问题

BackGround的问题
EN

Stack Overflow用户
提问于 2013-07-10 18:35:50
回答 1查看 73关注 0票数 1

我在图片中遇到了问题,我为我的应用程序创建了一个名为gridBg.png的背景,并以这样的方式阅读了它:

代码语言:javascript
复制
        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);

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-10 18:38:36

我甚至可以认为发生这种情况的唯一方法是,您的朋友的Working Directory没有设置为安装目录。这将导致currentDir出错。

根据MSDN文档GetCurrentDirectory这样做:

获取应用程序的当前工作目录

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17578371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档