相关疑难解决方法(0)

"asInvoker"和"highestAvailable"执行级别有什么区别?

我一直想知道嵌入有什么区别

<requestedExecutionLevel  level="asInvoker" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)

<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
Run Code Online (Sandbox Code Playgroud)

在你的应用程序的清单中.

.net manifest

36
推荐指数
2
解决办法
5万
查看次数

安装后程序找不到文件

我制作了一个程序,它使用一个包含网站列表的预制文本文件.现在在一些计算机上程序运行正常但是,在我的朋友计算机中它没有.

我检查我的Windows 7计算机中的2个程序,1 xp,我没有任何错误.这个程序在XP上使用了一段时间,现在我的朋友想在家里的Windows 7计算机上安装它,但程序在安装程序后找不到该文件.

这是他得到的错误:

System.IO.FileNotFoundException: file not found 'C:\Users\eli\AppData\Roaming\fourmlinks.txt'.
file name: 'C:\Users\eli\AppData\Roaming\fourmlinks.txt'
Run Code Online (Sandbox Code Playgroud)

问题是我将这个文件发送到主程序文件夹(应用程序文件)中,它仍然无法找到它.

这是我在程序启动时用来查找文件的代码:

sring path = "";
path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\fourmlinks.txt";
            System.OperatingSystem osInfo = System.Environment.OSVersion;
            if (osInfo.Platform == PlatformID.Win32NT)
            {
                if (osInfo.Version.Major == 5 && osInfo.Version.Minor != 0)
                {
                    //running XP
                    //path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\fourmlinks.txt";
                    path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\fourmlinks.txt";
                }
            } 
Run Code Online (Sandbox Code Playgroud)

你可以看到,我试图确保它可以在Windows 7和Windows XP上运行.

注意:我不介意改变我使用这个文件的方式,甚至以这种方式丢失并尝试完全不同的方式,这将适用于操作系统(赢7和XP).如果你建议我新的方式,我会很乐意试一试.

我的问题:

  1. 如何在某些计算机上运行该程序,在某些计算机中运行?
  2. 你会把文件放在程序文件夹以外的其他地方吗?

(对不起我的英语不好)

c# windows text-files winforms

1
推荐指数
1
解决办法
3582
查看次数

标签 统计

.net ×1

c# ×1

manifest ×1

text-files ×1

windows ×1

winforms ×1