I am trying to loop through a directory to search all xml files. I got this accomplish by doing Directory.EnumerateFiles and by finding every .xml type. The thing is now, there are some random xml files that are empty with no information written in them. I want to check for all files that do not have any information in them.  Code  foreach (string file in Directory.EnumerateFiles("/xmlFiles", "*.xml", SearchOption.AllDirectories)) {     //Find the XML File     XDocument doc = XDocument.Load(file);      //Check if the XDocument doc has no root element      if (doc == null)     {         Console.WriteLine(File + " has NO root element");     }     else     {         Console.WriteLine(File + " has a root element");     } }   I tried doing a if else statement comparing the file to null after parsing the xml file but I get a error when loading my file before I can compare it.  Error: System.Xml.XmlException: 'Root element is missing.'
I'm loading an XML document in my C# application with the following:  XDocument xd1 = new XDocument(); xd1 = XDocument.Load(myfile);   but before that, I do test to make sure the file exists with:  File.Exists(myfile);   But... is there an (easy) way to test the file before the XDocument.Load() to make sure it's a valid XML file?  In other words, my user can accidentally click on a different file in the file browser and trying to load, say, a .php file causes an exception.    The only way I can think of is to load it into a StreamWriter and simple do a text search on the first few characters to make sure they say "  Thanks!  -Adeena
How to launch terminal on login How could I get the terminal to be launched once I have logged in, so that typing commands is much simpler? What is the significance of the name Bleach? The name "Bleach" seems to be having no relevance to the plot unlike most other series. Was it just chosen at Kubo-sensei's whim or does it have some significance? Maybe some cultural significance associated with shinigami, etc. that I am now aware of? From yesterday, openweather extention on the top panel does not show the weather. Its shows "Please wait Loading".  I tried to find the solution. There was a post of creating account on openweather website and use API id. I found that it is a subscription base plan. There was a free plan which allows 60 calls free for weather data.  I thought that the extention is open source. And may be I deleted any package that is required to work the extention so I reinstall the OS. But there is no difference of doing that.    What could possibly go wrong any guidance? Methods to work around the problem of missing data in machine learning Virtually any database we want to make predictions using machine learning algorithms will find missing values ​​for some of the characteristics.  There are several approaches to address this problem, to exclude lines that have missing values ​​until they fill with the mean values ​​of the characteristics.  I would like to use for a somewhat more robust approach, which would basically run a regression (or another method) where the dependent variable (Y) would be each of the columns that have missing values ​​but only with the rows of the table that contain all the data , and predict the missing values ​​with this method, complete the table by the table and move to the next 'column' with missing values ​​and repeat the method until everything is filled.  But that gives me some doubts.  Why any column start? I believe that the one with the smallest missing values ​​until the one with the most  Is there any threshold of missing values ​​that is not worth trying to complete it? (for example, if this characteristic only has 10% of the values ​​filled would not it be more interesting to exclude it)  Is there any kind of implementation in traditional packages or other methods that are robust to missings? How can I remove snaps without losing GUI? I want to know how to check how many snaps programs/apps I'm running. Also, how to replace them (if possible) without losing GUI? What licence is subscriber content provided under 4.0, 3.0 or them all? How do I align the viewport to a face normal? I would like to align the view straight on to a face, perpendicular to the normal. How do I align the 3D viewport to the face of a mesh? Is it ever acceptable for a period to come after a quote at the end of a sentence? Can I use my Schengen visa for a completely different purpose and entry point? I am a non-EU national, permanent UK Resident. Recently, my work issued me with a multiple Schengen visa with Norway as the first (main) point of entry. Now I want to go on holidays to Greece - do I need to apply to Schengen visa again, as Greece is not Norway and I am not going there for work? Explosive AR(MA) processes are stationary? I'm trying to prove that if $\alpha(t)=(x(t),y(t))$ is a $C^2$ regular curve $(\alpha'\neq0)$ with constant and positive curvature, then $\alpha$ is on the circunference and if $\alpha$ is the circunference, then its curvature is constant.  I solved the second part since $\alpha$ is the circunference, then $\alpha(t)=(r\cos\theta,r\sin\theta)$, so $|\alpha'(t)|=r$, I need help in the first part.  Thanks a lot. I was presented with the following problem:      Prove that there exist solutions to $x^2+y^2=z^n$ for all $n$, with $x,y,z, n \in \mathbb{N}$   I showed that by taking any Pythagorean triple $x^2+y^2=z^2$ and multiplying by $z^{2(n-1)}$ we get $(z^{n-1}x)^2+(z^{n-1}y)^2=(z^2)^n$, which allows me to generate solutions easily for any value of $n$. I managed to find several similar questions on this site, such as  concerning the specific case $n=3$. I notice that all of these questions take a similar approach and start with a Pythagorean triple and use it to generate general solutions.  Is there a way to prove the statement (or better yet provide solutions to the equation) without first relying on Pythagoras? stackoverflow.com without OpenID is it possible to login/create user in stackoverflow.com without creating/login using OpenID? i hate using OpenID, it's really confusing if you create different user/account on different websites :(     Note: the following text was submitted as an edit suggestion. I approved it, giving the user the benefit of the doubt and assuming that it was the OP's other account. -   even when i want to post this question under my new openid, i still logged as the old user, so i can't view my own question when i logged under my userid Checking if date is weekend PHP How to explain in layman’s terms the significance of the difference of qubits of the D-Wave and IBM QX? So, @AndrewO mentioned recently that he has had 'encounters' with people wondering why D-Wave has a lot more qubits than IBM. Of course, this comparison is faulty, since the IBM and D-Wave's machine may both exploit quantum effects to a certain degree, IBM's machine matches the thing the TCS people call a 'Quantum computer' a bit more than D-Waves's alleged quantum annealer.   How do you explain to a novice why IBM is still reaching important milesstones, even though the D-Wave has a lot more 'qubits'. I understand that an easy answer is, 'well, you're comparing apples and pears', but that is merely relying on your possible authority and simply doesn't explain anything!   How can you explain that those devices are different, how can you dispell the myth that the number of qubits is not the only metric to judge quantum devices? (preferably to a layman, but assuming basic (undergrad?) physics knowledge is ok, if needed) Closed ball not a manifold. My book on differential geometry claims that a closed ball in $\Bbb R^n$ can never be a differentiable manifold because of the boundary points. The book doesn't really give an explanation for why this is true. Could someone provide more details please? thanks Let $\mathbb S = \varnothing$.      Then from the definition: $ \bigcap \mathbb S = \left\{{x: \forall X \in \mathbb S: x \in X}\right\}$      Consider any $x \in \mathbb U$.      Then as $\mathbb S = \varnothing$, it follows that: $\forall X \in \mathbb S: x \in X$ from the definition of vacuous truth.      It follows directly that: $\bigcap \mathbb S = \left\{{x: x \in \mathbb U}\right\}$      That is: $\bigcap \mathbb S = \mathbb U$. ()   Proofwiki uses the above "proof" to "prove" that intersection of the empty set is the whole universe.   My question is, is the use of vacuous truth really allowed in axiomatic set theory, like ZFC? I don't see how the use of vacuous truth is justified.   The next problem I can think of is that we cannot really "define" the elements of empty set (to my knowledge, there is no element in empty set) so how can we then prove as the above proof did? This seems to contradict the use of vacuous truth.  And of course, there is issue of using the whole universe as a set, and I don't think this is allowed.... (Maybe proof above is using a different axiomatic set theory, as I am using ZF-minded thoughts...) How do question bookmarks work? What does bookmarking a question mean? How do you bookmark a question? Do users get updates on their bookmarked questions? Are my bookmarks publicly visible? How do you see your own bookmarks? How do you see other users' bookmarks? How do you see which users have bookmarked a particular question? What impact does the bookmark system have on the voting system? Can I &quot;un-bookmark&quot; a question? Can I search within my bookmarks? Use of substitution into the integral $\int_0^2 \frac{\arctan x}{x^2+2x+2}dx$ This question: got some attention, but I didn't understand anything of it. Now I looked at the solution of the book and there is given the hint to use the change of variable $$x=\frac{1-t}{1+2t}$$ Could you please explain how one could think of such substitution? Is there some intuition behind this? Also after I used the substitution I got: $$\int_{-1/5}^1\frac{3\arctan\left(\frac{1-t}{1+2t}\right)}{5t^2+8t+5}dt$$ How can I finish this using the hint from the book? Photoshop CS6 Resize Rectangle with Rounded Corners This question is about Photoshop CS6. Hopefully the feature was added in this version. Before posting I looked up Google and  and  but didn't find an answer for CS6.  So the question is: Is there a feature within CS6 or a script that allows to resize a vector element with rounded corners without using the Direct Selection Tool (white arrow tool) and not changing the border radius? What would be great would be something like simply using the transform tool or something like a grid resize tool.