PlausiblyDamp
Administrators-
Posts
7016 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by PlausiblyDamp
-
Checking FileExists b4 StreamReader.
PlausiblyDamp replied to Jay1b's topic in Directory / File IO / Registry
how about declaring it it at the top and checking later on when you open the file dim sr as streamreader 'do other stuff here if file.exists(LogPath & ".hist") then sr = new streamreader(LogPath & ".hist") else 'error handled here end if -
wouldn't device.DrawPrimitives(PrimitiveType.LineList,.....) or device.DrawPrimitives(PrimitiveType.LineStrip,.......) do the trick instead of trianglelist / trianglestrip?
-
dataset.clear not what you are looking for. or adapter.update to push changes back.
-
Get my AOL e-mail without using their software [vb]
PlausiblyDamp replied to m7j4p7's topic in Network
bit of background: http://www.emailman.com/aol/#why bit of good news: http://www.betanews.com/article.php3?sid=1070617514 may not be worth the trouble of starting a large project.... -
Checking FileExists b4 StreamReader.
PlausiblyDamp replied to Jay1b's topic in Directory / File IO / Registry
Dim sr as streamreader try sr = New StreamReader(LogPath & ".hist") catch 'handle error end try would handle the error but why not just carry on checking first, not sure why making sure something can be done before doing it is 'old fashioned'. -
Sending/Receiving File over Encrypted NetworkStream
PlausiblyDamp replied to stavesacre's topic in Network
Just tried it with my boot.ini file (322 bytes) - worked a treat sending code is class Class1 { /// /// The main entry point for the application. /// [sTAThread] static void Main(string[] args) { System.Net.Sockets.TcpClient tcp = new System.Net.Sockets.TcpClient("localhost",12345); Send s = new Send(); s.sendFile("c:\\boot.ini",tcp.GetStream()); } } public class Send { TripleDESCryptoServiceProvider tripleDES; public Send() { tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = Encoding.Unicode.GetBytes("foobar12foob".ToCharArray()); tripleDES.IV = Encoding.Unicode.GetBytes("foob".ToCharArray()); } public void sendFile(String fileName, Stream networkStream) { FileStream fin = new FileStream(fileName,FileMode.Open, FileAccess.Read); //Create variables to help with read and write. byte[] bin = new byte[100]; //This is intermediate storage for the encryption. long rdlen = 0; //This is the total number of bytes written. long totlen = fin.Length; //This is the total length of the input file. int len; //This is the number of bytes to be written at a time. CryptoStream encStream = new CryptoStream(networkStream, tripleDES.CreateEncryptor(), CryptoStreamMode.Write); Console.WriteLine("Encrypting..."); //Read from the input file, then encrypt and write to the output file. while(rdlen < totlen) { len = fin.Read(bin, 0, 100); encStream.Write(bin, 0, len); rdlen = rdlen + len; //Console.WriteLine("{0} bytes processed", rdlen); } encStream.Close(); } } and receiving code is class Class1 { /// /// The main entry point for the application. /// [sTAThread] static void Main(string[] args) { // // TODO: Add code to start application here // Receive r = new Receive(); System.IO.FileStream fs = System.IO.File.OpenWrite("c:\\test.txt"); System.Net.Sockets.TcpListener tcp = new TcpListener(12345); tcp.Start(); r.receiveFile(fs,tcp.AcceptTcpClient().GetStream()); System.Console.ReadLine(); } } } public class Receive { TripleDESCryptoServiceProvider tripleDES; public Receive() { tripleDES = new TripleDESCryptoServiceProvider(); tripleDES.Key = Encoding.Unicode.GetBytes("foobar12foob".ToCharArray()); tripleDES.IV = Encoding.Unicode.GetBytes("foob".ToCharArray()); } public void receiveFile(FileStream fs, NetworkStream ns) { while(!ns.DataAvailable){} byte[] bin = new byte[100]; long rdlen = 0; int len = 100; CryptoStream decStream = new CryptoStream(fs,tripleDES.CreateDecryptor(), CryptoStreamMode.Write); Console.WriteLine("Decrypting..."); while(len > 0) { len = ns.Read(bin, 0, len); rdlen = rdlen + len; decStream.Write(bin,0,len); Console.WriteLine("{0} bytes read, {1} total bytes", len, rdlen); } decStream.FlushFinalBlock(); decStream.Close(); ns.Close(); fs.Close(); } -
Where/How does vs.net ide store custom toolbar info???
PlausiblyDamp replied to createdbyx's topic in General
:\Documents and Settings\Administrator\Application Data\Microsoft\VisualStudio\7.1\1033 in there there is a file called CmdUI.PRF that seems to contain the menu / toolbar layout. -
If you are reading it a line at a time you could then keep track of the line count based on each readline and treat the string as a character array. Dim srdr As StreamReader = New StreamReader("map/test/test.txt") Dim LineCount As Integer Dim ln As String Do LineCount += 1 ln = srdr.ReadLine() MessageBox.Show(ln) Dim ch() As Char = ln.ToCharArray For Each c As Char In ch MessageBox.Show(c.ToString()) Next Loop Until ln Is Nothing srdr.Close() or similar
-
As an external tool http://www.sysinternals.com/ntw2k/freeware/procexp.shtml is very good - new version supports .Net features like garbage collections run, classes / assemblies loaded etc. These can give some good idea of demand on the system. If you are running XP/ Win2K / NT4.0 you also have the System monitor which can target quite specific areas of cpu / mem /disk usage. These same counters can be accessed programatically through the System.Diagnostics.PerformanceCounter class. As to how to determine the requirements themselves running the app on a low memory / slow cpu system and seeing when it stops being usable - something like VMWare or MS Virtual PC can help in this case as you can create a virtual pc and artifically limit RAM available.
-
Unless it is very very simple VB6 code cut and paste will not work. There is a migration wizard which attempts (quite badly) to port your code to .Net - can't think of a single positive thing to say about the wizard though. The best way is really to redesign / rewrite the code under VB.Net, at least that way you can start to get the benefits of the framework etc.
-
I'm a little bit of a newb to .NET, but know 6.0...
PlausiblyDamp replied to griffyboy0's topic in Windows Forms
the Dim MyNewForm As New FormWiz MyNewForm.Show() should have worked - what happened when you tried this? Where did you call this code from(button click etc)? -
Dynamically Add MenuItems to MenuItems (in MainMenu) [C#]
PlausiblyDamp replied to Shaitan00's topic in Windows Forms
Which line do you get the error on? Could you post a bit more of the code like the foreach bit. -
You are trying to launch the application on the server - and if you check task manager you will see notepad gets loaded into the server's process list. However as it is launched from the ASPNET service it will not have access to the desktop. You cannot use server-side asp.net code to launch a client process that way.
-
This control array hangs the compiler when run...
PlausiblyDamp replied to FartNocker's topic in Windows Forms
something similar to Dim i As Integer i = System.Array.IndexOf(TB, sender) might do it (haven't tested it) -
My bad - VB makes me lazy like that. try the System.Array class' IndexOf method : string[] OptArr = {"one","two","three"}; int i; i= System.Array.IndexOf(OptArr,"two");
-
Was that a .Net error or one thrown by windows itself? If it is an OS error then it is probably happening before your application runs in this case so .Net exceptions wouldn't be able to handle it anyway.
-
OptArr.IndexOf()
-
Surely you can search on the exception name though - rather than the error message itself. Agreed my sample doesn't have handlers for all exceptions - I just used the ones that made most sense for the likey errors to occur in that given situation, as for exceptions raised by the OS itself not too sure what you mean there could you give an example?
-
The type of exception never changes between languages either though. The following snippet may give a better idea. Dim i As Integer Try i = Integer.Parse(TextBox1.Text) Catch ex As FormatException 'handle invalid data type here Catch ex As OverflowException 'handle nuber being too large here Catch ex As Exception 'anything else here MessageBox.Show(ex.ToString) End Try and you could always get the underlying exception type as a string for logging with something similar to MessageBox.Show(GetType(Exception).ToString())
-
If you are trying to reset the control on a form that is already open your code will not work as it creates a new instance of the form - you need to pass in the existing instance of your form as a parameter: Function ResetAllComboBoxesOnMainForm(FormMain as frmMain) 'This routine just resets all the conboBoxes text to say "Select" or "0" FormMain.cboNoNumbers.Text = "Select" FormMain.cboFindMatchingBalls.Text = "Select" FormMain.cboTopBalls.Text = "Select" FormMain.cboRandomPick.Text = "0" End Function
-
Why have you parameterised the procedure - you never use the @TFUname parameter in the body of the proc anywhere. Also why whould you expect the letter 'F' to be accepted as an integer, is the underlying field an integer or a letter?
-
Object reference not set to an instance of an object [C#]
PlausiblyDamp replied to Shaitan00's topic in General
change public Remote(int iO, int iM) { object[,] m_obj = new object[iO, iM]; } to public Remote(int iO, int iM) { m_obj = new object[iO, iM]; } as you are re-declaring the array within the constructor at the moment. -
Depends on the exception some like a SQLException contain an error number property based on the error code raised by SQL, but most do not. Unlike VB6 where the error number was all you had to go on to determine the problem exceptions are more OO - the exception itself denotes the type of error (InvalidCastException, OverflowException, DivideByZeroException etc.) Could you give a code sample of where you would need such a number - there may be an alternate way of solving the problem.
-
It would only bring back entries where the city field was both San Francisco and San Jose at the same time - you would never get any results back.