work with xml - Windows Phone 7 Development and Hacking

Hi all, i have a big problem to write file in xml.
For reading the file i hadn't problem but to write...
Well, i have created this simple xml:
<?xml version="1.0" encoding="utf-8"?>
<budget>
<entrate>
<titolo>titolo</titolo>
<descrizione>descr</descrizione>
<prezzo>1000</prezzo>
<data>24/02/2011</data>
<id>0</id>
<mese>2</mese>
<anno>2011</anno>
</entrate>
</budget>
and i have added thi into my project by "adding new existing item"
now i have this code to write the xml:
using (var applicationStorage = IsolatedStorageFile.GetUserStoreForApplication())
using (var speedListFile = applicationStorage.OpenFile("budget.xml", FileMode.OpenOrCreate, FileAccess.Write))
{
var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("budget",
new XElement("entrate",
new XAttribute("id", "t.Id"),
new XAttribute("subject", "t.Subject"),
new XAttribute("body", "t.Body"))));
document.Save(speedListFile);
}
and with this code in every case create a new file and don't use my file included into my project. why?
How can i open my file budget.xml of my project?
Thanks

Because files you save as content in your XAP aren't stored in isolated storage.
To use read from a file that's saved as content you need to use
var resource = System.Windows.Application.GetResourceStream(new Uri("{path to file}", UriKind.Relative);
of course, you cannot then save any changes to that file back to the content file. You'd need to save it in isolated storage.

Related

How do i get folder size rapidly?!

I write a C# app for WindowsMobile.
in order to get a nonrecursive folder size i have this routine:
Code:
static long GetDirectorySize(String path)
{
long size = 0;
String []files = Directory.GetFiles(path);
foreach (String f in files)
{
FileInfo fi = new FileInfo(f);
size += fi.Length;
}
return size;
}
now, my directory (in Storage Card) has about 1000 files that has about 4MB of data alltogether.
the GetDirectorySize takes forever to execute (60 seconds or so) and provide a horribole user expericnce.
executing this in a thread does not help either - i need the response as fast as possibole.
I was wondering if someone could help me figure out how to get folder size (nonrecursive) more rapidly.
in general, i also want to find the older file in the directory and delete it (kid of cache operation). how do i do that without waiting forever to complete?
storing an index file might not be what i'm looking for.
Thanks
I don't know about C#, but in C++ I use GetDiskFreeSpaceEx function, see HERE.
PS,
I think this goes in the Q&A forum?
dgaud007 said:
I use GetDiskFreeSpaceEx function
Click to expand...
Click to collapse
This does not help with Folder size.
My intention is to manage Cache folder and monitor its size and clear out some cached files in case the cache size of the folder is too big.
getting the disk size is not the way to deal with folder size
You can use it for individual folders, as the folder name is the 1st input parameter. I've used at least for \My Documents which is a regular folder and it works. Here is an excerpt from MSDN:
lpDirectoryName [in, optional]
A directory on the disk.
If this parameter is NULL, the function uses the root of the current disk.
If this parameter is a UNC name, it must include a trailing backslash, for example, "\\MyServer\MyShare\".
This parameter does not have to specify the root directory on a disk. The function accepts any directory on a disk.
The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
Click to expand...
Click to collapse
As per MSDN, here is how you implement it in C#:
Code:
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
internal static extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes);
I tested GetDiskFreeSpaceEx.
- The coredll has to be used instead kernel32dll (for WindowsMobile).
- the TotalBytes returns the SD card size (on which the folder exists)
- the freeBytesForUser equals FreeBytes and returns the free space in the SD card
this does return the folder size.
appreciate further help.
thanks
I double checked and you're right. Looks like you'll have to recurse while adding the individual sizes. I couldn't find an easier method in a brief search in google. Sorry about the confusion!
PS,
checkout this app...
I'm not that much of a C# expert but isn't the 1000 times calling "new" slowing down? I'd try to write a traditional C++ application using simple FindFirstFile and FindNextFile functions and compare speed towards the C# application. If it's faster then you can just build a C++ DLL and PInvoke her. I'm not sure if results are better but at least it's worth a try.
solution found
I managed to resolve this and get a speedy result by replacing with this code.
all the best.
Code:
private static long GetDirectorySize(String path)
{
long size = 0;
[COLOR="DarkGreen"] /* Slow code
String []files = Directory.GetFiles(path);
foreach (String f in files)
{
FileInfo fi = new FileInfo(f);
size += fi.Length;
} */[/COLOR]
DirectoryInfo di = new DirectoryInfo(path);
FileInfo []fi = di.GetFiles();
for (int i = 0; i < fi.Length; i++)
size += fi.Length;
return size;
}
btw: get my app at http://www.logelog.com/utils

[Q] WP7 - Removing an XElement from an XML file

Hi there,
I'm having a big issue, when trying to remove an XElement from an XML file created in IsolatedStorage.
--------------------------------------------------------------------------------------------
Code to CREATE the XML file
Dim File_to_Create As String = "Tracks.xml"
Dim file As XDocument = <?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlnsd="urn:schemas-microsoft-comfficedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Cartridges.xsd" generated="2010-11-23T14:26:55">
<Carts>
<CART_NAME>First</CART_NAME>
<CART_COLOR>White</CART_COLOR>
</Carts>
<Carts>
<CART_NAME>Second</CART_NAME>
<CART_COLOR>Black</CART_COLOR>
</Carts>
</dataroot>
Dim isoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Try
If isoStore.FileExists(File_to_Create) Then
MessageBox.Show(File_to_Create + " TRUE")
Else
MessageBox.Show(File_to_Create + " FALSE")
Dim oStream As New IsolatedStorageFileStream(File_to_Create, FileMode.Create, isoStore)
Dim writer As New StreamWriter(oStream)
writer.WriteLine(file)
writer.Close()
MessageBox.Show("OK")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
'open selected file
Dim isoStream As IsolatedStorageFileStream
isoStream = New IsolatedStorageFileStream(File_to_Create, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore)
Dim XML_File As XDocument = XDocument.Load(isoStream)
Dim Cart_Query As System.Collections.IEnumerable = From query In XML_File.Descendants("Carts") Order By _
CStr(query.Element("CART_NAME")) Descending, CStr(query.Element("CART_NAME"))
Select New Class_Cartridge_Data With {.Cart_Name = CStr(query.Element("CART_NAME")), _
.Cart_Color = CStr(query.Element("CART_COLOR"))}
Me.ListBox_Cartridges.ItemsSource = Cart_Query
isoStore.Dispose()
isoStream.Close()
End Try
--------------------------------------------------------------------------------------------
Code to ADD / EDIT XElement
Dim File_to_Create As String = "Tracks.xml"
Dim XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()
' Check that the file exists if not create it
If Not (XML_IsolatedStorage.FileExists(File_to_Create)) Then
Return
End If
Dim XML_StreamReader As New StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read))
Dim XML_Document As XDocument = XDocument.Parse(XML_StreamReader.ReadToEnd())
XML_StreamReader.Close()
' Update the element if it exist or create it if it doesn't
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c) c.Element("CART_NAME").Value.Equals("First")).FirstOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' Add new
Dim newProgress As New XElement("Cartridges", New XElement("CART_NAME", "Fourth"), New XElement("CART_COLOR", "Blue"))
Dim rootNode As XElement = XML_Document.Root
rootNode.Add(newProgress)
End If
Using XML_StreamWriter As New StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write))
XML_StreamWriter.Write(XML_Document.ToString())
XML_StreamWriter.Close()
End Using
--------------------------------------------------------------------------------------------
Now my issue and request for some help!
If I use
XML_XElement.Remove
then the following exception is raised whenever I try to "refresh" the bounded ListBox
System.Xml.XmlException was unhandled
LineNumber=37
LinePosition=12
Message=Data at the root level is invalid. Line 37, position 12.
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream)
at ListBox_Data_from_XML_LINQ.MainPage.Button_Create_XML_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
InnerException:
--------------------------------------------------------------------------------------------
In short, I can add or edit, but cannot DELETE an XElement...
Any ideas?
Thanks in advance!
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Ren13B said:
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Click to expand...
Click to collapse
Well, I did nothing special, just the XML_Element.remove, instead of adding a new xelement.
Then the error raises whenever I try to reopen the XML file.
My point is, how can I delete an specific xelement?
As far as I know, the following code should work
Code:
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c ) c.Element("CART_NAME").Value.Equals("First")).Firs tOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' remove the selected record
XML_XElement.Remove
End If
Honestly I don't know if the foregoing code is correct or if the issue is related to how WP7 handles the removal thus corrupting the original file.
Please let me know if you need anything else.
Any help is very appreciated!
PS: Thanks for the other replies, helped a lot!
Here's how I did it in c#. My xml file is very different than yours so the query will be different but the important parts are where you load and close the file streams and then write.
Code:
//Get users private store info
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream isoStream;
//open selected file
isoStream = new IsolatedStorageFileStream(list, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore);
XDocument xml = XDocument.Load(isoStream);
isoStream.Close();
//Find section
XElement sectionElement = xml.Descendants("section").Where(c => c.Attribute("name").Value.Equals(groupn)).FirstOrDefault();
//Find item and remove it
sectionElement.Elements("setting").Where(c => c.Attribute("name").Value.Equals(litem)).FirstOrDefault().Remove();
isoStream.Close(); //Seems unnecessary but it's needed.
//Write xml file
isoStream = new IsolatedStorageFileStream(list, FileMode.Create, FileAccess.Write, isoStore);
xml.Save(isoStream);
isoStream.Close();
Thanks again for your help, greatly appreciated.
However I'm still getting the same error.
Sorry for asking, but are you getting any errors when deleting in WP7 ?
My knowledge on XML is extremely new and I'm sure that I'm making some mistakes somewhere...
But so far, I cannot get past the same exception.
Seems that the XML gots "corrupted" after the delete operation.
On the other hand, if is not too much to ask for, using my current code, how will handle the delete of the selected record?
Thanks!
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Problem is my country is not listed so I cannot register...
Here is the C# version of my current code for adding/editing
Code:
public static void ADD_XML_Record()
{
string File_to_Create = "Tracks.xml";
var XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
// Check that the file exists if not create it
if (! (XML_IsolatedStorage.FileExists(File_to_Create)))
{
return;
}
StreamReader XML_StreamReader = new StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read));
XDocument XML_Document = XDocument.Parse(XML_StreamReader.ReadToEnd());
XML_StreamReader.Close();
// Update the element if it exist or create it if it doesn't
XElement XML_XElement = XML_Document.Descendants("Carts").Where((c) => c.Element["CART_NAME"].Value.Equals("dd")).FirstOrDefault();
if (XML_XElement != null)
{
XML_XElement.SetElementValue("CART_NAME", "bbbbb");
}
else
{
// Add new
XElement newProgress = new XElement("Carts", new XElement("CART_NAME", "dd"), new XElement("CART_COLOR", "ff"));
XElement rootNode = XML_Document.Root;
rootNode.Add(newProgress);
}
using (StreamWriter XML_StreamWriter = new StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write)))
{
XML_StreamWriter.Write(XML_Document.ToString());
XML_StreamWriter.Close();
}
}
I tried your code but I'm having a bad time making it to work.
If not a big deal, please could you tell me how to modify it ?
I mean, if a record is found, instead of editing, to remove it?
Honestly I'm stuck and any help is more than apprecisted!
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Ren,
Just to say thank you for your last code. I made a little mod and now it works ok!
Thanks a lot for helping me out!

[Q] Change source of image from .cs file

Hi. How would you go about to change the source of an image from the .cs file? I've tried this:
xaml.cs:
Code:
BitmapImage yesImage = new BitmapImage(new Uri("/Test;component/Images/yes.png"));
img.Source = yesImage;
The xaml file has a control <image Name="img" /> residing in it.
Would binding in some kind of way solve this?
Sorry for the basic question, but I've searched and wasn't able to find anything that covers this.
Hi,
You're doing it in the right way. I assume you know you're using a URI referencing an image in an external assembly (i.e. a referenced dll separate from the project your .cs file is in)? (in your case called 'Test').
Is the image definitely in an external assembly?
Is that assembly definitely called 'Test'?
Is the image you are trying to load marked as Build Action 'Content' in Visual Studio?
Here's some code that loads an image from an external DLL called Shared:
MyImage.Source = new BitmapImage(new Uri("/Shared;component/Icons/Tick.png", UriKind.Relative));
Here's some similar code that loads it from the same assembly as the .cs file:
MyImage.Source = new BitmapImage(new Uri("/Icons/Tick.png", UriKind.Relative));
Hope that helps,
Ian
That worked! I changed the images (that are local to the project) "Build Action" to "content" and added the UriKind.Relative to the URI and also removed the /Test;component/ from the address.
What i find odd though is that the images (that I added to a folder called Images in the project) had the Build Action set to Resource as default and when i added the source via the property box of Visual Studio to the image control in the XAML it inserted the "/Test;component/Images/yes.png" for me and the images were visible. When changing the Build Action to Content they were gone again.
Anyway, it works now. Thanks
Glad it helped

[Q] [Win 8 JS dev] Uglified, Concated, UTF-8 + BOM encoded JS files for a Windows App

Hey everybody,
I'm currently porting my company's webapp to Windows 8. As being written 99% in JavaScript, I just started a new Windows Store JS App project in Visual Studio and moved all of my code in. After some fixes, the app is running fine now.
For deployment, I'm using grunt with grunt-contrib-uglify to concat and minify my JS files. They are saved with UTF-8 encoding und the windows app runs fine using those minified scripts. But the WACK certification fails because those files don't contain the BOM (Byte Order Marker).
I now added a step to my grunt setup, which adds the BOM to those JS files by reading the filecontent as buffer and re-save it with \uFFEF (the BOM) at the beginning. That leads to correctly encoded files, passing the certification.
The funny part is:
When I run the app as Debug or Release right from VS (with debugger), the app is working fine.
If I bundle the app for store submit and start it with the debugger attached, it's also running fine. But if I start the app without the debugger, the scripts are not being loaded.
Do you have a tip for me?
ice8lue said:
Hey everybody,
I'm currently porting my company's webapp to Windows 8. As being written 99% in JavaScript, I just started a new Windows Store JS App project in Visual Studio and moved all of my code in. After some fixes, the app is running fine now.
For deployment, I'm using grunt with grunt-contrib-uglify to concat and minify my JS files. They are saved with UTF-8 encoding und the windows app runs fine using those minified scripts. But the WACK certification fails because those files don't contain the BOM (Byte Order Marker).
I now added a step to my grunt setup, which adds the BOM to those JS files by reading the filecontent as buffer and re-save it with \uFFEF (the BOM) at the beginning. That leads to correctly encoded files, passing the certification.
The funny part is:
When I run the app as Debug or Release right from VS (with debugger), the app is working fine.
If I bundle the app for store submit and start it with the debugger attached, it's also running fine. But if I start the app without the debugger, the scripts are not being loaded.
Do you have a tip for me?
Click to expand...
Click to collapse
Build project as release and THEN create the app package check for breakpoints. Also does it run uncompressed?
Can you provide the code or the package?
Toxickill said:
Build project as release and THEN create the app package check for breakpoints. Also does it run uncompressed?
Click to expand...
Click to collapse
Doesn't the Package process do the build on it's own?
It is working when I load all the single JS files (that grunt is merging into one) and add the BOM to all of them. If I just concat those files without compression/minification it's working, together with the added BOM it's not...
There are no errors (I added an error listener), they simply don't get loaded.
---
I tried your solution, but it ends the same. The interesting part is, if I use publish rather than build, it gets installed und IS running without a debugger. After packaging, it's not...
The marker you are adding is for the UTF format MS uses... However you are encoding to UTF-8...
Toxickill said:
The marker you are adding is for the UTF format MS uses... However you are encoding to UTF-8...
Click to expand...
Click to collapse
This is, basically, what I'm doing to those JS files after concat/minify:
Code:
var buf = grunt.file.read(fileName, { encoding: null });
var missingBOM = (buf[0] !== 0xEF && buf[1] !== 0xBE && buf[2] !== 0xBB);
if (missingBOM) {
grunt.file.write(fileName, '\ufeff' + buf, { encoding: 'utf-8' });
}
See here http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx
Im mobile so im sorry for link.. But you are using the wrong marker for the encoding see here for a table.
Toxickill said:
See here http://msdn.microsoft.com/en-us/library/windows/desktop/dd374101(v=vs.85).aspx
Im mobile so im sorry for link.. But you are using the wrong marker for the encoding see here for a table.
Click to expand...
Click to collapse
Hmm... but it's the same marker as VS adds when I'm manually saving them with UTF8-signed encoding. EF BB BF adds cryptical symbols but no BOM...
Can you create me a blank program compress it and send it to me so i can see if it does not work and i ca debug it as well.
Toxickill said:
Can you create me a blank program compress it and send it to me so i can see if it does not work and i ca debug it as well.
Click to expand...
Click to collapse
I'm sorry, I can't give out the code...
This is essentially what it does:
HTML:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="stylesheet" href="%dest%css/%lib-css%" />
<link rel="stylesheet" href="%dest%css/%app-css%" />
</head>
<body>
<div id="wrapper"></div>
<script>
var script = document.createElement('script');
script.async = false;
script.type="text/javascript";
script.charset = "utf-8";
script.onload = function() {
...
};
script.src = '%dest%js/%libs-js%';
document.head.appendChild(script);
var script = document.createElement('script');
script.async = false;
script.type="text/javascript";
script.charset = "utf-8";
script.onload = function() {
... (initialize app,...)
};
script.src = '%dest%js/%app-js%';
document.head.appendChild(script);
</script>
</body>
</html>
What my grunt script does is minify all JS files into app.js and libs.js, the CSS into app.css and libs.css and replace the %var% variables with the corresponding files/folders.
My script now writes the correct BOM to the file and also removes possible BOMs in the file left from the source files during merging:
Code:
var buf = grunt.file.read(dist + fileName, { encoding: null });
var BOM = new Buffer([0xEF,0xBB,0xBF]);
// remove multi BOMs from Buffer
var bufString = buf.toString('utf-8');
bufString = bufString.replace(BOM.toString('utf-8'), null);
buf = new Buffer(bufString, 'utf-8');
// add new UTF-8 BOM to the beginning of the file buffer
var bomFile = Buffer.concat([BOM,buf]);
grunt.file.write(dist + fileName, bomFile, { encoding: 'utf-8' });
I double-checked via a HEX editor that the resulting files 1. contain the correct BOM at the beginning and 2. don't contain any additional BOMs (neither the UTF8 nor the THF16 one).
Still, no luck launching the app without a debugger, my JS is not loaded/parsed...
No ideas guys?
ice8lue said:
No ideas guys?
Click to expand...
Click to collapse
Sorry, ive been working the 8.1 jailbeak, try keeping your scrips in the same directory and referencing them with the file name only...
This could be the problem....
Code:
%dest%js/%libs-js%
Im not familiar with JS windows store apps.
Toxickill said:
Sorry, ive been working the 8.1 jailbeak, try keeping your scrips in the same directory and referencing them with the file name only...
This could be the problem....
Code:
%dest%js/%libs-js%
Im not familiar with JS windows store apps.
Click to expand...
Click to collapse
No problem in general, but we're eager to release the app.
The code path is correct, these are variables, being overwritten during deployment.
Update:
It looks like it's really the combination of merged JS files by uglifyJS and the BOM that causes this problem. I now disabled the merge, loading all of the files seperately (but in a minified form) with the BOM added. The app now succeeds certification AND is running without a debugger.
This is ugly, but it's working - finally.

How to delete root element from xml file using csharp for wp

This the structure of my xml file
<?xml version="1.0" encoding="utf-8" ?>
<itemList>
<Item>
<Name></Name>
<Method></Method>
<Item>
</itemList>
I just entered some data into xml file through
var isoFileStream = new IsolatedStorageFileStream("itemList.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, store);
XDocument myData = XDocument.Load(isoFileStream);
var data = from query in myData.Descendants("Item")
select new itemList
{
TitleName = (string)query.Element("Name"),
LinkName = (string)query.Element("Method"),
};
lstShow.ItemsSource = data;
isoFileStream.Close();
Now i want to remove an element from an xml file dynamically,i just tried with
var isoFileStream = new IsolatedStorageFileStream("itemList.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, store);
XDocument xDoc = XDocument.Load(isoFileStream);
/* xDoc.Descendants("Item")
.Where(x => (string)x.Element("Name") == data.TitleName).Remove(); //How to remove the element from the xml
xDoc.Save(isoFileStream); */
isoFileStream.Close();
I couldn't figure the solution,need help.Thanqs in advance
Normally, you remove the element from its parent.
Also, stackoverflow is always great for programming questions.
This one answers your questions: http:stackoverflow.com/a/8382902/586754
(Not allowed to post links yet.)

Categories

Resources