C# application does not load XML file when putting the application to start with Windows

Asked

Viewed 98 times

0

I have an application that reads an XML file when opening, done this manually works, but if you put the application to start with windows the same does not read the file.

  • 2

    I don’t understand anything, put more details about the problem, be more precise in the problem (you look like it’s not even what you’re writing), circumstances, put your code.

  • I just wanted you to understand the following bigown, when I give two clicks he opens the application and reads the XML and arrow the texts in textbox, has a configuration that when checked starts with windows, but when starts with windows and open the application the fields are blank, now understood?

  • Not because you have not put new information. The way you are we have to guess how you are doing all this. Understand that you know your application, we don’t. If you do not detail the relevant parts to your problem of how it works, there is no way to help you. I understand the problem, I can’t understand what you’re doing in your application. It can be endless things. It may just be a permission/authorization problem, it may be that your code is doing things wrong that works by coincidence in a certain situation, among other things.

  • It may be that the program does not find the file path for example, when it starts double-click the path you specified works, but when windows starts the program, the path no longer points to the right place (it uses relative paths to the file?)

  • The windows itself takes care of this Ommi, when I go in msconfig.exe and see the programs that start with windows it is there, I click on "open file location" and it displays exactly in the location that this XML, the extension this . xml would have to do in . config?

  • @Brunorodrigues I ask again, what kind of path is it using? Relative or absolute? Even before you read the XML file, print the path to a file and confirm that it is correct.

Show 1 more comment

1 answer

1


If XML is in the same location as your executable, use the code:

string caminho = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "\\arquivo.xml");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.