.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

How to write xml file?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

I am having a three text box. I want to write the fields given in text boxes to xml file and the xml file should be open as save dialog box for the user to download the xml file. I want without saving the xml file in the physical path of the server 
Any idea let me know?


I am having a three text box. I want to write the fields given in text boxes to xml file and the xml file should be open as save dialog box for the user to

View Complete Post

More Related Resource Links

How to write in .dbf file with c#


Hi all

can anybody help me to solve my problem : writing in .dbf  , as following is my code with this error :

[ ERROR [07002] [Microsoft][ODBC dBase Driver] Too few parameters. Expected 3 ]


SqlConnection cn = new SqlConnection("Data Source=(local);Initial Catalog=test;Integrated Security=True");
        SqlDataAdapter da = new SqlDataAdapter("select * from test", cn);
        DataSet ds = new DataSet();
        da.Fill(ds, "test");
        string odbccon = "Dsn=TEST.DBF;dbq=E:\\FOX;defaultdir=E:\\FOX;driverid=533;fil=dBase 5.0;maxbuffersize=2048;pagetimeout=5";

        OdbcConnection connection = new OdbcConnection(odbccon);
        OdbcCommand createCommand = connection.CreateCommand();

        createCommand.CommandText = "CREATE TABLE test (ID int, name varchar(50),last_name varchar(50))";

Code write file asp.net 2.0 is working in firefox but IE not working.

If Not IsDBNull(ext) Then                                        ext = LCase(ext)                                    End If                                    Select Case ext                                        'Case ".htm", ".html"                                        '    type = "text/HTML"                   

Having issues with the webservice to write file

Is there anything extra I have to do with the webservice. If the aspx page with the upload control writes to the same "uploads" folder, then it works fine. Currently, only the asp.net account is permitted to write to that directory. When the webservice was introduced in it's place, I'm seeing permission issue stating the "Unauthorized" message. What's working: - User goes to .aspx page and use the upload control to upload the file What's not working - User goes to a fat client, and sends the file in a byte array to the webservice - It works if the webservice is on the same computer, but, fails if the fat client is run on a different computer Best Regards, Rajib Bahar http://www.rajib-bahar.com | http://www.linkedin.com/in/rajibb | http://www.twitter.com/rajib2k5

WPF Desktop App - Write file permissions

I have been working on a WPF desktop app for a while now, and I am struggling to deploy it.  The problem seems to be that the app does not have permissions to save the file I am creating.  Although I should say the code works fine running locally through Visual Studio. I am OneClick deploying the app, and just want to give it full access although just knowing how to give it write permission is all I need.  The app is only to be used by a few members of staff on our intranet, so trust is not really an issue here. If anyone can point me in the direction of a quick solution that would be great, and you'll save me alot of time trying to figure out all the documentation which I am failing to work out what to do with so far. Additional info: I am deploying over a web address, which I think means Internet Zone. Thanks John

how to write data to excel file

Hi, can any one plz tell me how to write data in and excel sheet. when i retrive the data by foreach loop i want to dynamicaly create a excel sheet and save data inside the sheet.  Please help

How to write a stylized XML file to a text file?

Hello All,I am using the <asp:xml> tag on front end and I am supplying the Document Content(data source) as well as the transform source(XSL file) on the back end to display the stylized XML on a web page.Now, I want to write the transformed result to a text file. I want to fetch the transformed XML without having to parse through the source HTML. Any suggestions will be greatly appreciated.Thanks.

Write html file through webservice

I am writing an application in which I want to generate dynamic html file based on the parameters of jquery objects. I want to pass the parameters to a webservice which will produce the required html page. How I can achieve it. Is there any other good approach to this problem.

how to write error free in js file

When i add the below code in the javascript file (JS file ) i am getting error :   adding below code in the apsx page do not have problem <script src="http://munchkin.marketo.net/munchkin.js" type="text/javascript"></script> <script>mktoMunchkin("476-IFP-265");</script>   converting the above to include in anotehr js file gettign error : unknown error mktoMunchkin in IE 7 document.write('<script type="text/javascript" src="http://munchkin.marketo.net/munchkin.js"></script>');document.write('<script type="text/javascript">mktoMunchkin("476-IFP-265");</scr' + 'ipt>');   am i doing any error please let me know Thanks in advance      

write Custom MemberShip provdider only to read the connection string from other file

hi,    In asp.net mvc project I am using MYSQlMemberShipProvider. Now I want that instead of reading the connection string from web.config file, it will read the connection string from external file every time. So that I am implementing the cutsom mebership provider class, this class inherits the MemberShipProvider class.    But the problem is that if I inherits the MemberShipProvider class then I have to impelment all of its method in my cutsom membership provider class, But I want to use all other inbuilt methods of MemeberShip. What can i do.I only want to add the code like below: public class CustomSqlMembershipProvider :MembershipProvider    {        public override void Initialize(string name, NameValueCollection configs)        {            base.Initialize(name, configs);                Connectionstring objProducts = // redaing the connection string.   }}But on compiltaion it is giving me the error does not implement inherit abstract member. Please Suggest me any idea.        Thanks In AdanaceAayushi

How to read/write GIANT text file with no line breaks


I have to process giant XML files that are 6GB+ in size.  The problem is that there are no line breaks in the file, and the XML is improperly formatted (no root element).  Therefore I can't use the XML class to read the file, and I can't open the file in any text editor or even "Type" it in a command window because the 1 line in the file is over 6GB.

The file contains UTF8 characters.  What I want to do is first write a program just to read and display 100 characters at a time so I can look at the contents.  Next I want to be able to create a new file, write a root element, read/write the contents of the file and then write the closing root element.

Can anyone provide a code snippet of how to read and display the file contents 100 characters at a time.  I can then figure out the rest.


Problem while 2 User write in a File a the Same time


Hi Everyone
I am facing a problem while a user is going to write in a file. My question is that if a User A open a file and start writing in file usin FileStream, if at the same other user try to access this file and try to write in it then he should wait until User A does not complete his work and close writer object.  Waiting for quick response. It is very urgent. Thanks in advance.


not able to write error to event log and log file



I am using entlib 5.0 and framewokr 3.5(vs.net 2008)

I opened entlib console and open the webconfig file and added the listeners and my webconfig file is as below

<?xml version="1.0"?>
  <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				<sectionGroup name="webServi

Using XMLReader and XMLWriter to read and write to a config.xml file


I have a c# program, and I have created an initialization.xml with some attributes.  One of the attributes is an output directory location that the user enters.  I want to be able to open the init file and write this directory path to the outputLocation attribute of the init xml file.

I know how to read xml files using XMLReader and create and write new XML files with XMLWriter, but not sure how to go about open an existing file, moving to a specific attribute, and writing the value to it.

I am assuming this is pretty straight forward.



Using response.outputstream.write to stream large file fails in firefox



I have some code to stream files (for security of the files), the code works for all files in IE, and small files in firefox. but If the file is large (eg 750Mb) firefox hangs before it shows the open/save dialog box. 

However if i take out response.clearheaders and the response.flush in the code it does download but all the files downloaded by firefox are corrupt because the file size is too large.   Filenames are guids but I took the "-" out incase that was an issue.

If any one can shed some light on this I would be very grateful.

Function is Below. 


Private Sub StreamFile(ByRef response As HttpResponse, ByVal sFile As String)
            Dim fs As FileStream = Nothing
            Dim sFileName As String = Path.GetFileName(sFile)

            Dim oFile As New FileInfo(sFile)

                fs = New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)

            Catch ex As Exception

            End Try


            'response.ClearHeaders() 'makes file size wrong in firefox
            response.AddHeader("Content-Length", oFile.Length)
            'To forcefully download, even for Excel, PDF files, reg

Trying to write google video sitemap xsd file


I'm trying to write a gogole video sitemap xsd file, to auto generate video sitemaps.

There is a prefix for the video section <video:video> that I can't seem to get. I get <tns:video> instead

I think it's a namspace issue or I need to add a prefix?

This is my source

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - FREE Community Edition (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            XML Schema for Video Sitemap files. Last Modifed 2010-10-05
  <xs:element name="urlset">
        <xs:element minOccurs="0" maxOccurs="unbounded" name="url">

XML file - write attributes in root element


i have to write the following XML file using .net 2005.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

- <IMPORTFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ARC_Carrier_Import.xsd">

Tring to write to web.config file error Access to the path


Hi Friends.

Actually i m trying to make a setupfile for my project.That makes some processes and at the end of processes will change web.config Database connectionstring values and will run project.Evertthing is good but cant reach to web.config file beacuse of permissions.
Project will run on out of company hosting account.So i cant reach IIS to change permissions.

So please offer me a way or if you know solution.Please help.
I also thinking on downloading web.config file with ftp account and change it and reupload back with programaticly in code.
Waht you think???

System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Access to the path 'C:\Inetpub\vhosts\xxx.com\httpdocs\rouqudck.tmp' is denied. (C:\Inetpub\vhosts\xxx.com\httpdocs\web.config) ---> System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\xxx.com\httpdocs\rouqudck.tmp' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, B

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