|
Thank you very much for your reply.
|
|
|
|
|
Hi all...
I'm trying to write to a file with the XmlDocument class. I used the Save(string) method which gets a file location and saves the XML to it. the thing is I get an exception:
"The process cannot access the file 'c:\scene.xml' because it is being used by another process".
What is the problem? how can I overcome this? (I want to load the file and then to be able to save on the that file)
some code:
this happens when loading of the file
_currentXMLFile = openXMLFileDialog1.FileName;
System.IO.StreamReader myXMLFileStream = new System.IO.StreamReader(_currentXMLFile);
XmlTextReader myXMLTextReader = new System.Xml.XmlTextReader(myXMLFileStream);
_myXMLDocument = new System.Xml.XmlDocument();
_myXMLDocument.Load(myXMLTextReader);
myXMLDocument is defined at the start of the program so it will have the program's lifespan.
this happens when trying to save the XML document into a file, and throws an exception:
myXMLDocument.Save(fileName);
|
|
|
|
|
Hi,
if you're running Windows Vista or higher, you are not authorized to create files in certain locations of your boot partition; the top level directory is one of them. So choose another location, there is an excellent way to get some here: Environment.GetFolderPath() Depending on the kind of file and data, look for ApplicationData or MyDocuments or ...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Actually I'm using windows XP...
I tried the procedure (load and save) on many locations and it still throws the error.
it there a way to load and save the same file, did any one tried that??
|
|
|
|
|
Make sure you close the file where you load it, the "another process" part of the error message often is incorrect.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
ok, even though the System.IO.StreamReader is defined within a function?? (the function ends before the save action)
|
|
|
|
|
yes, you have to close or dispose of it explicitly, or use a using statement which is a way to get it disposed of automatically. There is no "stack semantics" stuff in C#, and the GC will only execute finalizers if and when new memory allocations cannot be satisfied without collecting first (and even then finalizers run on a low-priority thread), so that can take a long time to happen.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Closing the streamReader did solve the problem... you are awesome!
one more question on a relative topic:
XMLNode myXmlNode;
for (int i=0; i < 2; i++)
{
myXmlNode = new XMLNode;
}
will the GC collect the first two allocations of the XMLNode? and when?
|
|
|
|
|
Hi,
you have to add () to make that compile...
and I see only two allocations. The first is collectible right away, as the only reference (in myXmlNode) gets overwritten by the second one; I can't see where the second one becomes collectible, as the enclosing code block is absent.
And collectible isn't the same as collected, as I already explained.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Can I get the code of any *.exe file?? If yes how?
because I lost my source code for my application. But I installed it before it is lost ... and I have the exe file with me ....... what do u recommend me to do??
|
|
|
|
|
Sure, get Red Gate's Reflector (previously from Lutz Roeder), for native programs, well, there is a thing called Boomerang, but it is not that good so you'd be better off with a disassembler for native code.
|
|
|
|
|
IMO, given your previous posts it's doubtful you want this for genuine purposes. It's more likely you want to decompile someone else's application, and, again from your previous posts, it's highly unlikely you would even understand it.
If this is not the case, then it's a good lesson for you in how to use source control and backups.
only two letters away from being an asset
|
|
|
|
|
hey dude ..... that is not the case .... i didnt know that exe files will be converted to back ..... after I know it(i.e yesterday) I remembered there was one application that I did for my customer and I remembered I lost it with virus ...... but the exe file is still on my pc .... that is why i post this question... if you can help am here...
Thank you
|
|
|
|
|
Hey dude...then it's a good lesson for you in how to use source control and backups.
only two letters away from being an asset
|
|
|
|
|
you omitted too many periods to make that sink in I'm afraid.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
why dont u say ..... I cant... i think it hard 4 u to say that
|
|
|
|
|
Hello,
How l can make a form to blink (after some event occured)?
10x alot
|
|
|
|
|
It's not a question of how, but why. IMO, it would be a horrendous UI.
only two letters away from being an asset
|
|
|
|
|
I think he means, "flash the title bar", ala Windows Messenger, not "a form that blinks on and off".
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
|
|
I expect that's what form.Activate() does.
|
|
|
|
|
Hi,
How can i start a new window at the position of the right bottom of the screen,
no matter of what the size of a screen i have.
Thanks...
modified on Saturday, August 8, 2009 12:09 PM
|
|
|
|
|
1) Find out where your right bottom is
2) Set the correct properties on the form
Screen.PrimaryScreen.Bounds.Width;
Screen.PrimaryScreen.Bounds.Height;
Enjoy
I are Troll
|
|
|
|
|
My right bottom is directly beside my left bottom, on the seat of the chair.
|
|
|
|