C#部署 [英] c# deployement

查看:85
本文介绍了C#部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在xp中安装了C#应用程序,但可以正常工作,但是当我在Windows7安装中成功安装了相同的应用程序时,但是当我启动该程序时,该程序说访问被拒绝,我在应用程序中使用了此代码字符串windowsFolder = Environment.GetFolderPath (Environment.SpecialFolder.System);


i installed C# application in xp it is working but when i installed the same application in windows7 installation is successfully but when i start the program that time the program saying access denied i used in the application this code string windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);


DataTable dt = new DataTable();

                DataColumn dc = dt.Columns.Add("custid", typeof(Int32));

                dt.Columns.Add("id", typeof(string));

                DataRow dr = dt.NewRow();

                dr["custid"] = 1;

                dr["id"] = "santhu";

                dt.Rows.Add(dr);

                dt.TableName = "santhu";

                string s1 = windowsFolder + @"\XMLFile3.xml";

                StreamWriter xmldoc = new StreamWriter(windowsFolder + @"\XMLFile3.xml");

                dt.WriteXml(xmldoc);

                xmldoc.Close();



我如何在Windows 7中运行该应用程序?



how can i run the application in windows 7

推荐答案

我强烈怀疑,如果使用windowsFolder引用该文件夹,则会导致此问题顾名思义.

例如,您应该使用一个通用数据文件夹"All Users \ ApplicationData \ whatever \ XMLFile3.xml".
I strongly suspect that it is your use of windowsFolder that is causing the problem, if it references the folder that it''s name suggests.

You should use one of the common data folders ''All Users\ApplicationData\whatever\XMLFile3.xml'' for example.


我怀疑您需要另一个文件夹路径,因为vista和Windows7不会.不要让您的应用程序写入系统文件夹,我建议
I suspect you need another folder path as vista and windows7 won''t let you application write to the system folder, I suggest
<pre>Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);


Windows文件夹在Windows 7上受保护.您可以

  • (简单的解决方法)将文件写入另一个(不受保护的)文件夹.
  • (不是那么简单的解决方案)与UAC进行合作以提升应用程序的特权
    (例如,请参见以下"UAC示例" [ ^ ]).
Windows folder is protected on Windows 7. You may either

  • (The simple workaround) Write your file to another (unprotected) folder.
  • (The not so simple solution) Deal with UAC to elevate the privileges of your application
    (see, for instance, the following "UAC Sample"[^]).


这篇关于C#部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆