473,770 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My windows giveth xml and it taketh away! Include path!

I wrote a screensaver, via Visual Studio 2003 in C# and I decided a wiser
choice for me was to use an xml file to save my configs. Btw: I wonder if
this is why every bit of documentation I've found for saving configuration
info in an xml file speak of only doing this for web programming in fact, I
get the impression that they have been slipped a mickey that made them
forget that there are programs out there that are not web based, but I
digress ...

I could have done a regular config files be just a regular text file, but I
figured, I might as well do it with xml like everyone else is doing, so
remove all my registry config saving stuff and replace it with a simple
class that uses an in-memory only dataset and table tries to read the xml
file named "SwarmIni.x ml" and if it doesn't exist, create one by building
the config schema on the in-memory table, and then populating a row or rows
with my config data and create the file. WriteXml over-writes the xml file,
so I didn't have to worry about deleting the file.

It worked fine as long as I named the file swarm.exe, the file and the
config screen would track. However, when I renamed the exe to .scr all kinds
of strange things would happen. First, I would watch it create the xml
values, I would bring up config and change a value, shut down the
screensaver, reload it and see that the new values were there, and then I'd
get curious and open up the xml with notepad and find the OLD values there!!
Notice I say that it worked normally as long as it ended in exe but seemed
to be working with some sort of ghost-xml file with new values AND create a
visible xml file that did not track with my config changes. It was not a
case of different names, the file name was a constant, in only ONE place in
the program.

It was as if windows was kidnapping the xml file!! Despite doing a search
telling it to include system32 and all system subdirectories, it would find
any file except xml files, even non-xml files in system32 but it would not
find that file I was seeing right there in front of my face! Now ain't this
strange??

I solved it! I simply included the application path so that the config.xls
file created was SwarmIni.scr.co nfig.xls and then no matter how I named the
extention, the data in the config screen, and that in the xml file would
track.

So, while I never ever did find out what was happening, I did cure it by
specifying the path. I suspect that windows is kidnapping a copy of the xml
file and redirecting things some how. I still can't get search to find my
xml files tho. I have show hidden and show system files turned on.

I learned three important rules of xml programming ....

1. Always specify a path, never just give it a name and trust it to create a
file in the location you expect, without this bizarre non-tracking behavior
cropping up.

2. Never, ever copy your write method to the read method and change the name
of the method and the code to do the reading. What I did by accident, was
that I had the read method, callling the write method IF the file did not
exist, which was fine and dandy, but in the branch I executed when the file
already existed, I had a read early on and a spurious DataTable.Write Xml
call, but writing an xml file while my xml helper class was supposed to be
reading, and hadn't disposed of the table doing the reading yet, caused some
strange feedback loop to start. My program would appear to execute, but some
process would end up looping, and my hard drive light would start thrashing
like crazy. There was no visible process, and the every time I ran my saver,
everything looked ok, but my computer would flash, lag, the hard drive would
do more and more thrashing, creating nothing that I could see and all kinds
of strange things would happen which are too many to list ...

3. It is unfortunate that xml is so similar to xls - excel's spreadsheet
extention. I have to be extremely careful not to accidentally name something
as xls instead of xml. In C++ I would have created a global #define in one
place and forget about it, but in C# there isn't such a thing as a global
constant visible throughout all the projects in a solution, so be careful
out there!

4. I am a bit wary about this saving config info in xml format tho. Sure,
it's portable, and its nice to read it and locate values, but it's also
portable to malware that might be able to read those value and change them,
and perhaps cause some sort of havoc by trying buffer over-runs and other
stuff. In other words, I worry about this, that it might create a security
hole here. An ini file I write, could have been in any format, and could
have anything in it in any order, but an xml file, is predicable, and
standard, and makes it an easy pickins target. Don't get me wrong, I don't
dislike xml format. It's great for moving data and sharing it, but I wonder
if it's such a great place to store config info. I think more security needs
to be put into place. Perhaps xml with encrypted contents?

RambleMode = Off.

--
To reply to this message take off the .NoJunkSpam off of the end of
ga******@pacbel l.net.NoJunkSpam
Nov 12 '05 #1
2 1558
Nope Windows will not touch the file. My guess is your screen saver is
writing to the file on shutdown and clobbering the updated values that way?

If you just call it .xml then you won't conflict with the special magic
..config files. .config files are meant for management of the deployment of
an app, it's for the IT guys to mess with and your app usually just reads
them. So settings that your app actually saves would be in a separate file.

"Garry Freemyer" <ga******@pacbe ll.net.byespam> wrote in message
news:Or******** ******@TK2MSFTN GP10.phx.gbl...
I wrote a screensaver, via Visual Studio 2003 in C# and I decided a wiser
choice for me was to use an xml file to save my configs. Btw: I wonder if
this is why every bit of documentation I've found for saving configuration
info in an xml file speak of only doing this for web programming in fact, I
get the impression that they have been slipped a mickey that made them
forget that there are programs out there that are not web based, but I
digress ...

I could have done a regular config files be just a regular text file, but
I figured, I might as well do it with xml like everyone else is doing, so
remove all my registry config saving stuff and replace it with a simple
class that uses an in-memory only dataset and table tries to read the xml
file named "SwarmIni.x ml" and if it doesn't exist, create one by building
the config schema on the in-memory table, and then populating a row or
rows with my config data and create the file. WriteXml over-writes the xml
file, so I didn't have to worry about deleting the file.

It worked fine as long as I named the file swarm.exe, the file and the
config screen would track. However, when I renamed the exe to .scr all
kinds of strange things would happen. First, I would watch it create the
xml values, I would bring up config and change a value, shut down the
screensaver, reload it and see that the new values were there, and then
I'd get curious and open up the xml with notepad and find the OLD values
there!! Notice I say that it worked normally as long as it ended in exe
but seemed to be working with some sort of ghost-xml file with new values
AND create a visible xml file that did not track with my config changes.
It was not a case of different names, the file name was a constant, in
only ONE place in the program.

It was as if windows was kidnapping the xml file!! Despite doing a search
telling it to include system32 and all system subdirectories, it would
find any file except xml files, even non-xml files in system32 but it
would not find that file I was seeing right there in front of my face! Now
ain't this strange??

I solved it! I simply included the application path so that the config.xls
file created was SwarmIni.scr.co nfig.xls and then no matter how I named
the extention, the data in the config screen, and that in the xml file
would track.

So, while I never ever did find out what was happening, I did cure it by
specifying the path. I suspect that windows is kidnapping a copy of the
xml file and redirecting things some how. I still can't get search to find
my xml files tho. I have show hidden and show system files turned on.

I learned three important rules of xml programming ....

1. Always specify a path, never just give it a name and trust it to create
a file in the location you expect, without this bizarre non-tracking
behavior cropping up.

2. Never, ever copy your write method to the read method and change the
name of the method and the code to do the reading. What I did by accident,
was that I had the read method, callling the write method IF the file did
not exist, which was fine and dandy, but in the branch I executed when the
file already existed, I had a read early on and a spurious
DataTable.Write Xml call, but writing an xml file while my xml helper class
was supposed to be reading, and hadn't disposed of the table doing the
reading yet, caused some strange feedback loop to start. My program would
appear to execute, but some process would end up looping, and my hard
drive light would start thrashing like crazy. There was no visible
process, and the every time I ran my saver, everything looked ok, but my
computer would flash, lag, the hard drive would do more and more
thrashing, creating nothing that I could see and all kinds of strange
things would happen which are too many to list ...

3. It is unfortunate that xml is so similar to xls - excel's spreadsheet
extention. I have to be extremely careful not to accidentally name
something as xls instead of xml. In C++ I would have created a global
#define in one place and forget about it, but in C# there isn't such a
thing as a global constant visible throughout all the projects in a
solution, so be careful out there!

4. I am a bit wary about this saving config info in xml format tho. Sure,
it's portable, and its nice to read it and locate values, but it's also
portable to malware that might be able to read those value and change
them, and perhaps cause some sort of havoc by trying buffer over-runs and
other stuff. In other words, I worry about this, that it might create a
security hole here. An ini file I write, could have been in any format,
and could have anything in it in any order, but an xml file, is
predicable, and standard, and makes it an easy pickins target. Don't get
me wrong, I don't dislike xml format. It's great for moving data and
sharing it, but I wonder if it's such a great place to store config info.
I think more security needs to be put into place. Perhaps xml with
encrypted contents?

RambleMode = Off.

--
To reply to this message take off the .NoJunkSpam off of the end of
ga******@pacbel l.net.NoJunkSpam

Nov 12 '05 #2
Nope, I wasn't writing on shutdown. If it did write, it would be the new
values.

I suspect, that somewhere, I had it saving to a different area and never
noticed while fixing. I read about the .config stuff, so I named mine
Swarm.scr.confi g.xml, and haven't had a single issue since. It could also be
because I had that extraneous write in the read operation, it was setting up
some sort of loop, the read, caused a write, while trying to read I suspect,
but it's all working perfectly now.
"Chris Lovett" <so*****@nospam .please> wrote in message
news:h7******** ************@co mcast.com...
Nope Windows will not touch the file. My guess is your screen saver is
writing to the file on shutdown and clobbering the updated values that
way?

If you just call it .xml then you won't conflict with the special magic
.config files. .config files are meant for management of the deployment
of an app, it's for the IT guys to mess with and your app usually just
reads them. So settings that your app actually saves would be in a
separate file.

"Garry Freemyer" <ga******@pacbe ll.net.byespam> wrote in message
news:Or******** ******@TK2MSFTN GP10.phx.gbl...
I wrote a screensaver, via Visual Studio 2003 in C# and I decided a wiser
choice for me was to use an xml file to save my configs. Btw: I wonder if
this is why every bit of documentation I've found for saving configuration
info in an xml file speak of only doing this for web programming in fact,
I get the impression that they have been slipped a mickey that made them
forget that there are programs out there that are not web based, but I
digress ...

I could have done a regular config files be just a regular text file, but
I figured, I might as well do it with xml like everyone else is doing, so
remove all my registry config saving stuff and replace it with a simple
class that uses an in-memory only dataset and table tries to read the xml
file named "SwarmIni.x ml" and if it doesn't exist, create one by building
the config schema on the in-memory table, and then populating a row or
rows with my config data and create the file. WriteXml over-writes the
xml file, so I didn't have to worry about deleting the file.

It worked fine as long as I named the file swarm.exe, the file and the
config screen would track. However, when I renamed the exe to .scr all
kinds of strange things would happen. First, I would watch it create the
xml values, I would bring up config and change a value, shut down the
screensaver, reload it and see that the new values were there, and then
I'd get curious and open up the xml with notepad and find the OLD values
there!! Notice I say that it worked normally as long as it ended in exe
but seemed to be working with some sort of ghost-xml file with new values
AND create a visible xml file that did not track with my config changes.
It was not a case of different names, the file name was a constant, in
only ONE place in the program.

It was as if windows was kidnapping the xml file!! Despite doing a search
telling it to include system32 and all system subdirectories, it would
find any file except xml files, even non-xml files in system32 but it
would not find that file I was seeing right there in front of my face!
Now ain't this strange??

I solved it! I simply included the application path so that the
config.xls file created was SwarmIni.scr.co nfig.xls and then no matter
how I named the extention, the data in the config screen, and that in the
xml file would track.

So, while I never ever did find out what was happening, I did cure it by
specifying the path. I suspect that windows is kidnapping a copy of the
xml file and redirecting things some how. I still can't get search to
find my xml files tho. I have show hidden and show system files turned
on.

I learned three important rules of xml programming ....

1. Always specify a path, never just give it a name and trust it to
create a file in the location you expect, without this bizarre
non-tracking behavior cropping up.

2. Never, ever copy your write method to the read method and change the
name of the method and the code to do the reading. What I did by
accident, was that I had the read method, callling the write method IF
the file did not exist, which was fine and dandy, but in the branch I
executed when the file already existed, I had a read early on and a
spurious DataTable.Write Xml call, but writing an xml file while my xml
helper class was supposed to be reading, and hadn't disposed of the table
doing the reading yet, caused some strange feedback loop to start. My
program would appear to execute, but some process would end up looping,
and my hard drive light would start thrashing like crazy. There was no
visible process, and the every time I ran my saver, everything looked ok,
but my computer would flash, lag, the hard drive would do more and more
thrashing, creating nothing that I could see and all kinds of strange
things would happen which are too many to list ...

3. It is unfortunate that xml is so similar to xls - excel's spreadsheet
extention. I have to be extremely careful not to accidentally name
something as xls instead of xml. In C++ I would have created a global
#define in one place and forget about it, but in C# there isn't such a
thing as a global constant visible throughout all the projects in a
solution, so be careful out there!

4. I am a bit wary about this saving config info in xml format tho. Sure,
it's portable, and its nice to read it and locate values, but it's also
portable to malware that might be able to read those value and change
them, and perhaps cause some sort of havoc by trying buffer over-runs and
other stuff. In other words, I worry about this, that it might create a
security hole here. An ini file I write, could have been in any format,
and could have anything in it in any order, but an xml file, is
predicable, and standard, and makes it an easy pickins target. Don't get
me wrong, I don't dislike xml format. It's great for moving data and
sharing it, but I wonder if it's such a great place to store config info.
I think more security needs to be put into place. Perhaps xml with
encrypted contents?

RambleMode = Off.

--
To reply to this message take off the .NoJunkSpam off of the end of
ga******@pacbel l.net.NoJunkSpam


Nov 12 '05 #3

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

Similar topics

35
7768
by: Vamsi Mudrageda | last post by:
I am kind of new to Python, and after trying and using wxPython, I found it kind of lacking in easy-to-read documentation, speed at loading, and GUI response-time. So I am looking for an another GUI toolkit that is cross-platform for Python, and am leaning toward PyQt (PyGTK is kind of dull looking in comparison). Unfortunately, although TrollTech says Qt is cross-platform, its license strategy has me a bit confused. So here is to...
4
1796
by: mrw | last post by:
I was wondering how you create that default error beep that you dear when say you go to start, then run, and type in a bad filename. You here a specific sound. It must be some type of API or something, right? Since that sound can be changed to whatever you want and the new sound will still play. That to me tells me that it isn't just code that plays a sound but some API call to the "Asterisk" sound which then points to the whatever...
22
2113
by: Stan Weiss | last post by:
I have a program writeen in Microsoft QC 2.5 for DOS which has a very simple interface of using printf and sscanf also gets and puts. Is there an easy way to convert this to Window? Thanks Stan
4
5481
by: timb | last post by:
Hi, I have windows service, in the event of an exception calling (which is important enough to write away to a customer event log) i would like to write away the software version as part of the evenetlog message text. I have used the following code with existing windows forms applications System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly ..GetExecutingAssembly.Location).FileVersion ; but am unable to use it...
8
1356
by: Comics | last post by:
Does Microsoft remove Win32 from Windows in next Windows release? Does .NET cover low lovel API too?
9
15613
by: Karthikeyan.T.S | last post by:
Hi, I am getting a error when I try to start a Windows Service. The error is "The XYZ service on local computer started and then stopped.Some services stop automatically if they have no work to do,for example, the performance logs and alerts service." I don't know why it is throwing such a error. kindly advise. Thanks in Advance. Regards,
10
10053
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to believe that this has to do with unreleased form component events or event handlers. I'm comparatively new to .net and windows forms, in the sense that though I've been using them for over 2 years now, it's been rather sporadic. I work with...
10
2164
by: deathtospam | last post by:
My employer is starting to take the first steps towards migrating its Classic ASP codebase to ASP.NET v2.0. We have a copy of our existing website on the new Windows Server 2003 R2 test server, and everything is running fine. However, when I create a simple "HelloWorld.aspx" file, then browse to the page from VS.NET 2005 on the same machine, I get the following error message: ================================================ Server...
2
11733
by: sambo251 | last post by:
After running a few updates I get this very annoying "Windows Installer" error #1706 that will ne go away! It keeps saying that it cannot find the file "instantsharedevices.msi", that it is on another CD, and gets caught in a loop when I try to delete it! It mentions MS.net frame error # 1706. The "details" code follows...hope someone can help me to either fix it or get out of the loop! I tried running "Windows Registry Repair Pro"...but no help...
30
6988
by: diane | last post by:
I've got an application running with table-based security: i capture the user's windows login with fOsusername, then have them enter a password checked against their username/login in my own table. The problem is, they can't remember the passwords they've created, and I spend more time than I want to resetting. Here's what I'd LIKE to have happen: when the user opens the application (Access2k), a dialog box appears with the windows...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
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
10101
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...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
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
6710
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();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.