|
I wouldn't have thought so then, you might want to take a look through the CryptoStream's methods with Reflector, I've always found it useful.
I've just taken a look through and the CryptoStream does not override the Close method so defaults to Stream's Close method which in turn calls the Dispose method, which kinda sucks
So no it doesn't look as though you can without copying the entire stream
|
|
|
|
|
Just checked it out with Reflector and yeah you're right, there's no way around it.
It'll close the underlying stream.
thanks for the tip about Reflector.
|
|
|
|
|
gumi_r@msn.com wrote: thanks for the tip about Reflector.
Saved my ass more than once
|
|
|
|
|
|
|
thanx, and good idea but im working on that stinky RAS thing which i dont seem to quite handle.. i actuall want to disconnect a remote adsl modem connected to the server "really disconnect not fool around ", basically my company wants to cut down running costs like this one which i have to disconnect just after 4 hours of daily usage.. this's what im trying to do..
try
{
RASCONN lprasConn = new RASCONN();
lprasConn.hrasconn = IntPtr.Zero;
IntPtr m_ConnectedRasHandle;
m_ConnectedRasHandle = lprasConn.hrasconn;
RAS.RasHangUp(m_ConnectedRasHandle);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
thanx a million code-frog for trying to help, but never mind, nobody seems to know how to solve this
ps. i tried this article as well.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I said before: you're passing a null handle into RasHangUp which will be returning an error code. You need to pass it a handle to the connection you want to disconnect, which will be the one returned from RasDial if you created the connection, or one you get back from RasEnumConnections .
|
|
|
|
|
Thank you Mike
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Muammar© wrote: but never mind, nobody seems to know how to solve this
The problem isn't that noone knows how to solve the problem. It's that you're not listening or understanding the explanation of why your code isn't working.
You created a new RASCONN object, then set one of it's properties to IntPtr.Zero, then you retrieved that very same IntPtr.Zero from the property and passed it as a parameter to RasHangUp. What you passed was not a valid handle to an existing connection. You just made up your own handle that doesn't have any meaning and tried to get RadHangUp to disconnect it. It can't disconnect a handle that doesn't represent a valid connection.
Let me rewrite your code to show you what you did:
try
{
RAS.RasHangUp(IntPtr.Zero);
}
RasHangUp returns a value which you are ignoring. API calls like this will NOT throw an exception because they know nothing of the .NET Framework. If you read the documentation on RasHangUp, you'll see that it returns 0 if the call is successful, or a non-zero value if it fails. This non-zero value is the error code.
What you should be doing to get the code is:
int rc;
rc = RAS.RasHangUp(validHandle);
if (rc != 0)
{
}
else
{
}
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
|
IT WORKS!! thanks a million Dave!! I'm listing it here for anyone sick of RAS
RASCONN lprasConn = new RASCONN();
lprasConn.hrasconn = IntPtr.Zero;
int lpcb = 0, lpcConnections = 0;
lpcb = Marshal.SizeOf(typeof(RASCONN));
RAS.RasEnumConnections(ref lprasConn, ref lpcb, ref lpcConnections);
RAS.RasGetConnectionStatistics(lprasConn.hrasconn, stats);
IntPtr m_ConnectedRasHandle;
m_ConnectedRasHandle = lprasConn.hrasconn;
MessageBox.Show(Convert.ToString(RAS.RasHangUp(m_ConnectedRasHandle)));
Thanks again Dave
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
Thank you Vasudevan
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello,
Does anybody know what is new in .Net 3.0 related to file archiving methods?
If nothing new, what classes from .Net 2.0 are recomanded in doing this task?
Thanks,
Lukas
|
|
|
|
|
".NET 3.0" is a stupid Microsoft marketing name. Absolutely nothing has changed in the CLR, WinForms or ASP.NET from 2.0 - it's exactly the same binaries. The only new stuff is in WPF, WCF, Workflow Foundation and ObjectSpaces.
|
|
|
|
|
What do you mean by archiving? You mean adding files to a zip or rar file?
|
|
|
|
|
Hello, again!
By Archiving I mean adding files\directories to a zip or rar file.
Thamk you for your interest!
Lukas
|
|
|
|
|
Lukas22 wrote: dding files\directories to a zip or rar file.
Thamk you f
Lukas, you have a number of options: the System.IO.Compression APIs[^] in the .NET framework v2. You can use the free and open source #ZipLib[^]. You can also use the J# runtime zip libraries[^]. I recommend using the #ZipLib -- I've heard about some nasty bugs in the System.IO.Compression APIs, and the J# zip libraries forces a dependency on the J# libraries, which aren't installed by default on most .NET setups (including the default Windows Vista install). So, I recommend #ZipLib.
|
|
|
|
|
Hello My application is often launched while the user is logged on via Remote Desktop Connection. My question is-is there any way for my application to determine if it is being launched in this way. Because of Directory permissions my application writes configuration files to the hard drive. Alot of the people that log in via Remote desktop connection do not have rights to the directory, this is the scenario and the customers IT dep. does not want to change it. So I will be able to open the app in readonly mode if it is launched via RDC Connection. Do you know how to do this or can you point me in the right direction.
BTW the config files are written to the user Docs & Settings\user folder\application data\Our Company\Configuration file. I am using .Net 2003 C# of course.
Thanks in advance for any information.
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|
|
|
There is no difference between a user logging in over Remote Desktop and the same user logging in at the console (i.e. at the physical keyboard). You should work out whether the file you intend to write is writable, which you should do simply by trying to open it for writing. Ensure that you don't accidentally truncate it in the process!
|
|
|
|
|
Thank both you and Vasudevan Deepak Kumar for your responses.
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|
|
yes there is.
google...[^]
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
I can assure you that I do not need Beginner Tutorials, thanks for the insult though. My suggestion is that if you do not have anything pertinent to say, please quit trolling.
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|