I had a situation that was not sure how best to deal with this. Entrance will be appreciated. Imagine I have a method like this:
void loaddata()
{
try
{
Savesomething(listOfObjects, xmlPath);
xmlPath = newValue;
xmlDoc = DecryptAndloadXMLdata(xmlPath);
listOfObjects.Add(objectFromXML);
}
catch(Exception ex)
{
xlmPath="";
}
}
Now the thing is, when the application leaves, I have such a function for automatically saving the List object, the method filled in above, to a file. How:
void whenAppisQuitting()
{
Savesomething(listOfObjects, xmlPath);
}
But that is the problem. Imagine xmlDoc = loadXMLdata();throwing the method above. What happens, the list I mentioned will not be filled, and when the application leaves empty elements (for example, empty listOfObjects), it will be written to xmlPath- thus, damage to my source file, because there was an unrelated exception due to encryption in loadXMLData.
, . ? , , , xmlPath catch - , - , - , , xmlPath ="". ?
, - ?
user4930657