Anusha
Anusha

Reputation: 1

setup file is not working fine on client machines

I created a windows form application and my application will read the data from the two xml files in which these files are stored in application bin\debugger folder ,these files will change while running the application and also my form is using the windows media player and some other xml files which are stored in the system drives.

I created a setup file like below procedure right click on Solution > Add > New Project >setup name

in Application folder I added two xml files and while adding the primary output of application i got a pop up box saying that it depends on the wmp.dll i added that one also.

created a shortcut for primary output ,cut and pasted into user's desktop and next in User Program i created a new folder in that folder i created a shortcut for primary output of an application and named as a setup file next I builded the setup file and after wards and I installed the setup in developed code machine its working fine but when i install the setup file on another computer it is not working please tell me what will be the reason, i'm struggling for this since from 3 days

Note: I added the system drives files in that locations before application running on the client computer

public partial class Form1 : Form
{
    XmlDocument SysDetails = new XmlDocument();
    XmlDocument UsrDetails = new XmlDocument();
    Public Form()
   {
    string filePath1 = Application.StartupPath; 
    string org1 = filePath1+ "\\UserFirstDetails.xml";
    UsrDetails.Load(org1);
    XmlNode NdeFirst= UsrDetails.SelectSingleNode("UserFirstDetails/IsFirstTime");
    FirstTime = NdeFirst.InnerText;
    if (FirstTime == "True")
    {
      NdeFirst.InnerText = "False";
      XmlNode productnum = UsrDetails.SelectSingleNode("UserFirstDetails/ProductOrderNum");
      productnum.InnerText = ProductNo;
      UsrDetails.Save(org1);//here i'm getting an exception ,please help me
                            in setup project it is points to C:\Program Files\Default Company Name\Setup Project, How to make C:\Project Files folder ReadOnly attribute to false
    }
   }
}

Upvotes: 0

Views: 105

Answers (1)

PhilDW
PhilDW

Reputation: 20790

Based on the code sample and the Access Denied error...

Programs cannot write to the ProgramFiles directory unless they are elevated to admin level. So there are two solutions:

  1. There are directories for user data, such as Application Data Folder, User's Application Data Folder etc, and that's where data files should be created and updated, and installed to, not the Program Files directory.

  2. If your program does a bunch of things that require admin privilege and you decide that users need to have admin privilege to run it, then give it an elevation manifest so there will be an elevation dialog when the program starts up.

There's an article here: http://www.codeproject.com/Articles/17968/Making-Your-Application-UAC-Aware

Upvotes: 0

Related Questions