.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Xml File Methods and Properties

Posted By: Syed Shakeer Hussain     Posted Date: August 01, 2010    Points: 2   Category :Others
Method and Properties of XmlTextWriter class:
The XmlWriter class is a base class that outputs an XML data structure. It has methods to sequentially write XML elements in a proper hierarchy to create an XML file or other types of output streams. The System.Xml namespace provides support for the XmlWriter. It must be imported to the ASP.NET page with the directive

<%@ Import Namespace="System.Xml" %>

The XmlTextWriter

XmlWriter is an abstract class that is implemented as an extended XMLTextWriter class. The XmlTextWriter writes a sequence of XML nodes one element at a time. Output can be written to an XML file, although other streams of output data can be produced. It can create a new file or overwrite an existing file. Its non-cached writing techniques provides very fast generation of an output stream.

View Complete Post

More Related Resource Links

Version history file properties



I move files into different folders programmatically. If a file was changed and it will be move again the new file is the actual file and the old file remained in the verison history.

How I save the new version:
SPFile destfile=website.getFile(destUrl);

Normally when you upload the new file with changed properties manually you see the changed properties in the version history.
When I do this programmatically I have the new file with the main version but the changed properties would not be displayed.
Can anybody help me?

Thanks and Regards

Cannot save Configuration File ["ConfigurationSection properties cannot be edited when locked."]


I have the following code Segment

public Form1()
	Configuration MyConfig;
	ExeConfigurationFileMap MyMap = new ExeConfigurationFileMap();

	MyMap.LocalUserConfigFilename = Application.UserAppDataPath + @"\" + Application.ProductName + ".xml";
	MyMap.RoamingUserConfigFilename = Application.LocalUserAppDataPath + @"\" + Application.ProductName + ".xml"; ;
	MyMap.ExeConfigFilename = Application.CommonAppDataPath + @"\" + Application.ProductName + ".xml"; ;

//	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.None );
	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.PerUserRoaming);
//	MyConfig = ConfigurationManager.OpenMappedExeConfiguration(MyMap, System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal );

	MyConfig.AppSettings.Settings.Add("Now", DateTime.Now.ToString() );


I am running for the 1st Time and trying to create the initial Config file.

I get an exception "ConfigurationSection properties cannot be edited when locked." on the MyConfig.Save() method.  This happens with the OpenMappedExeConfiguration( ...PerUserRoaming ...PerUser

Why SharePoint Workspace does not allow to edit file properties



I am not able to edit Document Properties defined in SharePoint 2010 Document Libraries from SPW 2010. 

  1. I create a SharePoint 2010 Workspace from an empty SharePoint 2010 Document Library;

  2. I add 10 PDF documents to SPW document library

  3. I click "Properties" on each of that files, but I only I get the "View Item Properties - Read Only" window, and can't edit any property

Note that I'm able to add/remove documents, so I'm not sure it's a permissions problem.

What I'm I missing?

Thank you in advance,


Recover last version of file properties in MOSS document library


After an overwrite to several hundred files we need a quick way to either restore the entire file to the previous version or ideal just the custom property fields.

I tried to find a way to script a query into the document library and collect the previous version custom data into an excel spreadsheet but could not find a solution.

I came across this post that indicated he was able to restore only the file properties but retained the current version (which was not his gold but would be mine).


He included a snippet of his code:

Would this work? is there a powershell equivalent?

Whats the easies way to make this code into a useful solution.


int versionCount = item.Versions.Count;
if (versionCount > 0)
// this only restores properties

Text box Properties / Action and url calling a file:\\ SQL Server 2008 R2



I have installed the new version of sql server 2008 r2.  It looks like it does not support file:\\ in the url only http, https, ftp, mailto and news.  I need to use file:\\dir\filename.ext any idea of how to do this.


Thank you again



Error when saving file from Word: This file cannot be saved because some properties are missing or


I am receiving an error when trying to save a file from Word into SharePoint: "This file cannot be saved because some properties are missing or invalid"

I have got two different Content Types for this Document Library: "Policies" and "Procedures". Both documents have got exactly the same required fields, all required fields are displayed in the Document Information Panel. If I try to save a "Policy" the saving process works fine, if I try to save a "Procedure" I get the above error.

It's as if the Procedure had an additional required field, but I cannot figure out where that would come from? If I go to manage the Content Types and check the list of fields, I can clearly see which fields are required and which aren't.

Is there something I am missing? Or could one Content Type be corrupt? If so, how do I fix it without messing up all the files that have already been posted using this Content Type?

Parsing C# Classes, Methods, and Method Properties Using Regex's


I have a web project that allows multiple developers to contribute to a .cs file in the App_Code folder. I need to dynamically report on which classes exist in the file, which methods are in those classes, which properties are expected by those methods, and what the method returns. I can't seem to get my curly brace matching to work using regex's.

I went down the road of trying to dynamically build the code and then use reflection to enumerate the objects, but I don't think that's going to work.

Any help would be appreciated.

Resetting properties in web deployment project based on custom build config file


I'm trying to create a general build environment for multiple projects that can take a some command line parameters and execute a build based on a custom config file.

The problem I am having is after I read in the config parameters with MSBuild.Community.Tasks XMLQuery, which works fine, I can't get aspnet_complier to see these parameters.

I keep getting "error MSB3462: Either MetabasePath or VirtualPath must be specified."

 Here is my project file:

<Project InitialTargets="PreMessage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
   <Target Name="PreMessage">
    <Message Text="Building..." />
 <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tas

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

WCF Tip: Using Properties in Service Contracts

you'll notice all of the Service Contracts are implemented with interfaces containing only methods. For the longest time I thought that's all that was supported, until I thought about it a little more. In C# land, properties are simply wrappers around a get method and set method, so why wouldn't we be able to use properties in a service contract? Well the answer is we can.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

The Decorator Pattern & Extension Methods

Numerous design patterns exist in the software world today, and ultimately nothing is preventing you from making your own (if people buy into it or not is another question). Furthermore, there is no 'master list' of patterns that all developers agree upon. While this is true, if you pick up any book on the subject, you will find a set of very common patterns most programmers agree are very useful. Many of these patterns were first formalized in the seminal book on the subject, Design Patterns: Elements of Reusable Object-Oriented Software (aka, the Gang of Four [GOF] book; not to be confused with the UK punk band of the same name).

Automatic vs Explicit Properties

If the reason that motivated the change from automatically implemented property to explicitly implemented property was to change the semantics of the property then you should evaluate whether the desired semantics when accessing the property from within the class are identical to or different from the desired semantics when accessing the property from outside the class.

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend