If your XSL file is for example 400 bytes long, your read operation will read somewhere between 1 and 399 bytes (both extremes included).
It can never 400 as you tell it to read fs.Length - 1
It is not even certain it will read 399 bytes, as any stream can choose to chunk any way it likes. The only thing you know for sure is that it will return minimum 1 byte (as long end of file has not been reached) and maximum the number you specify.
Either loop the read (you get the number of bytes read in the return value), or use a BinaryReader which offer the possibility to read a fixed number of bytes without any chunking (it will simply do the looping for you).
I have a menustrip in my project and in this i have some items like File,Edit,Help
and i have set mnemonic for these items with & like(&File,&Edit,&Help) so when i am in design mode
i can see the underscore with all first letters but when i run the project i can't see .
But i want to see it , please tell me how can i do it?
Any help would be appreciated.
Press the alt key to show those. This is standard Windows behavior. If you want to change it, go to Control Panel -> Display -> Appearance -> Effects -> "Hide underlined letters for keyboard navigation until I press the Alt key", and uncheck that option.
Since I lack a mentor I have to ask these basic structure question here. Good guidance is really appreciated. Please be advised that I am thinking of both Python and C# structure; but generalities are good too:
Classes: What should go into a class and what should stay out?
-I am converting a program to have an OOP structure the program prints out processed results to a file line by line. Should my class for this return the processing results to the main program and then use a function or another class to print the results?
-Is it acceptable to have a class return some result but then call on the same class object to process the next logical step of the process? This seems right to me since built in functions seem to do this.
Have MyClass read the first line in a file, return it
Have the main print the line
Have the main call MyClass again but have it read the next line in the object
Should I just forget about "functions" and "sub-routines" and throw everything into classes?
Well, there wasn't a question about a struct... but
A structure can't inherit from a class (and vice versa) and a struct is created then dies when reaching the closing brace. It is a different animal but no it doesn't have to be defined within a class, but if you use it (write or read a member) that HAS to be inside a class...
So the message I seem to be getting is that, anything can be done from anywhere as long as it works. So if it seems write to have MyClass.Function0 return a value and dump that value to a file it is technically OK.
Aside from logical organization is there anything style wise I should know? For instance it would not seem right to have MyClass.Function both return a value and print those same values; I seems right to have a seperate class.function take the return values from MyClass.Function and do the writing. That would allow me to have multiple funcitons access my file writing function and eliminate repeat code.
my programm reads/writes an xml file. Here is how:
Yes,it's necessary that way. My problem is, when I open the Windows Explorer (WinXp sp2) and look into that folder, after some time i get an exception that the file is openend partially by an user.
This happens EVERYTIME at the same codeline: doc.save(myfile) (doc = xmlDocument).
Why is that happening?
Can i prevent that? If not, how can i handle that exception, without Thread.sleep loops?
Please help me!
Im willing to bet that you've not disposed properly of the stream when you open the file, hence when you come to write it there is already another process holding onto it (ie, your own program from earlier on during the read op)