473,854 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PROBLEM WITH OpenFileDialog WITH XML

MAYBE SOMEBODY CAM HELP

I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM
DIALOG

OpenFileDialog openFileDialog = new OpenFileDialog( );
OpenFileDialog. Filter = " Access (*.mdb)|*.mdb|A ll files (*.*)|*.*";
if (openFileDialog .ShowDialog() == DialogResult.OK )
DataBaseLocatio n.Text = openFileDialog. FileName;

THIS WORKS GREAT AND I GET THE LOCATION PUT IN A TEXT BOX
HERE COMES THE PROBLEM, I WANT TO SAVE THIS LOCATION IN AN XML FILE
(DOCUMENT) STORED ON THE PC. HERE GOES MY CODE FOR XML
XmlTextWriter TW=new XmlTextWriter(" dbfile.xml",nul l);
TW.WriteStartDo cument();
TW.WriteStartEl ement("Database ");
TW.WriteElement String("Databas eLoc",cf.DataBa seLocation.Text );
TW.WriteEndElem ent();
TW.WriteEndDocu ment();
TW.Close();

THIS CODE WORKS FINE ONLY IF I TYPE IN THE LOCATION INTO THE TEXTBOX
MSELF, I AM THAN ABLE TO CREATE AN XML FILE ON THE PC. IF I USE THE
OPENFILEDIALOG TO SELECT A FILE, THIS IS WHERE I HAVE THE PROBLEM.
FIRST IT DOES NOT CREATE A XMLFILE AT ALL EVEN THOGUH THE INFORMATION
SHOWS UP IN THE TEXT BOX, IF I CLOSE THIS DIALOG AND REOPEN IT GIVES
THE IMPRESSION IT READ THE XML FILE AND DISPLAY THE FILE I SELECTED
EVEN THOUGH THERE IS NO PHYSICAL XML FILE, IT APPEARS AS IF IT'S
STILL IN MEMORY AND NOT COMMITING THE WRITE. IF I EXIT THE
APPLICATION AND RESTART IT I CAN NO LONGER PULL UP THE XML FILE.

doES ANYONE HAVE ANY IDEA WHAT THE PROBOLE CODE BE, AM I USING A
REFERNCE RATHER THAN ACTUAL STRING, THATS WHY XML CAN'T COMMIT TO THE
WRITE? OR IS THIS A BUG? ANY HELP ON THIS WOULD BE GREAT

THANKS

Nov 16 '05 #1
1 3617
I was able to make it work with a minor change. I dropped cf in the line
below.
TW.WriteElement String("Databas eLoc",cf.DataBa seLocation.Text );
If that does'nt work & you still think that the content in memory is not
being commited to a disk, try doing Flush() on the Writer.

-Naraen

-----
"bobrad" <bo*******@comc ast-dot-net.no-spam.invalid> wrote in message
news:40******** @127.0.0.1... MAYBE SOMEBODY CAM HELP

I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM
DIALOG

OpenFileDialog openFileDialog = new OpenFileDialog( );
OpenFileDialog. Filter = " Access (*.mdb)|*.mdb|A ll files (*.*)|*.*";
if (openFileDialog .ShowDialog() == DialogResult.OK )
DataBaseLocatio n.Text = openFileDialog. FileName;

THIS WORKS GREAT AND I GET THE LOCATION PUT IN A TEXT BOX
HERE COMES THE PROBLEM, I WANT TO SAVE THIS LOCATION IN AN XML FILE
(DOCUMENT) STORED ON THE PC. HERE GOES MY CODE FOR XML
XmlTextWriter TW=new XmlTextWriter(" dbfile.xml",nul l);
TW.WriteStartDo cument();
TW.WriteStartEl ement("Database ");
TW.WriteElement String("Databas eLoc",cf.DataBa seLocation.Text );
TW.WriteEndElem ent();
TW.WriteEndDocu ment();
TW.Close();

THIS CODE WORKS FINE ONLY IF I TYPE IN THE LOCATION INTO THE TEXTBOX
MSELF, I AM THAN ABLE TO CREATE AN XML FILE ON THE PC. IF I USE THE
OPENFILEDIALOG TO SELECT A FILE, THIS IS WHERE I HAVE THE PROBLEM.
FIRST IT DOES NOT CREATE A XMLFILE AT ALL EVEN THOGUH THE INFORMATION
SHOWS UP IN THE TEXT BOX, IF I CLOSE THIS DIALOG AND REOPEN IT GIVES
THE IMPRESSION IT READ THE XML FILE AND DISPLAY THE FILE I SELECTED
EVEN THOUGH THERE IS NO PHYSICAL XML FILE, IT APPEARS AS IF IT'S
STILL IN MEMORY AND NOT COMMITING THE WRITE. IF I EXIT THE
APPLICATION AND RESTART IT I CAN NO LONGER PULL UP THE XML FILE.

doES ANYONE HAVE ANY IDEA WHAT THE PROBOLE CODE BE, AM I USING A
REFERNCE RATHER THAN ACTUAL STRING, THATS WHY XML CAN'T COMMIT TO THE
WRITE? OR IS THIS A BUG? ANY HELP ON THIS WOULD BE GREAT

THANKS

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5738
by: Bonzo | last post by:
Hi, How do I simply open a text file into a textbox? I know that in C++ I'd use something like: if(OpenDialog1->Execute()) Memo1->Lines->LoadFromFile(OpenDialog1->FileName); How can I do it in vsnet c#? THX
3
2548
by: michael haller | last post by:
In my project i have a textfile witch i import in my c# application. The datas in the textfile i show the datas in the textfile in my datagrid..ok that ist not my problem. Now i have a dataset (dataset.xsd the name is ds_BESR). How i can my datas in the datagrid into this dataset ds_BESR? Please help me...i need that. the reasen is my crystal report get the datas
6
1809
by: chau_fai | last post by:
I have a window Form called "Form2". There is only one button and a panel returned from a static method of the "Coord" in this form. In the panel returned, there is a button that can choose image from "OpenFileDialog" and then display it in a picturebox. This actually works properly before the button1 is clicked. Button1 is a button to open a new form and again it gets a panel returned from the static method inside "Coord" and perform the...
3
360
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access (*.mdb)|*.mdb|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) DataBaseLocation.Text = openFileDialog.FileName;
4
8014
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in Explorer i am getting error saying that cannot delete that folder as some process is using it. After that i selected a file from the same folder in OpenFileDialog. When i tried to delete the folder after selecting the file also it is giving the...
5
7126
by: Sonia Igla | last post by:
Hi. I use in my windows c# project External Dlls(Assembly.LoadFrom(dllName);...). All work fine. I add to one of my forms using of OpenFileDialog. First time I call this form It works. Next times I get Error: "File or assembly name Extended.dll, or one of its dependencies, was not found." in all modules this dll is using. This happen only by OpenFileDialog selects files (by cancel not
0
1078
by: Ion | last post by:
Hi, I have a ListView that is filled with selected paths from OpenFileDialog. Some times ListView is not redraw after OpenFileDialog close. I tried to fill paths to ListBox. I got the same problem. Invalidate() and Refresh() did not help. I tried to fill paths to TextBox, just for test only. Everything work fine, but I have to use ListView or ListBox.
4
2401
by: bbembi_de | last post by:
Hello everyone, I have a C# program that runs a batch from the command line. I use the following code for that: String arguments = "/C CALL batchfile.bat"; ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe"); startInfo.Arguments = arguments; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true;
0
954
by: pyda001 | last post by:
Hi yall! I have created an image selection dropdown editor for use in a PropertyGrid. My selector form is called dropdown by a IWindowsFormsEditorService and so far it's all sweet. On my selector form I have placed a lot of pictures the user can select from. I have also placed a button with "From File..." that opens an OpenFileDialog (Remember that this is still in the dropdown dialog form of the PropertyGrid). The problem is that...
11
14281
by: kimiraikkonen | last post by:
Hi, Vb.net 2005 express i've been working, the problem is: I use openfiledialog to browse files, i created some code to execute file with OK button, no problem. But if i press "cancel" button as the result of openfiledialog box, for example my filename's are added into listbox or my audio file is being played from the beginning. To explain better: openfileplaylist.ShowDialog()
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10679
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10370
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7914
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5741
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5941
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4154
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.