Hello, I am not 100% sure about that, but the methods seem similar to the HttpRequest. The "request stream" is not readable, because you make your request to the server through it, it is a writable stream. There is another stream, the "response stream" which is sent to you after you call GetResponseStream() at some class (guess it was the request, too). Get request stream, write data into if you need, get response stream, read it. Regards, d.mon
Daniel Monzert
Posts
-
Editing a file over FTP -
command line usage of cscHello, you'll find CSC options in the MSDN documentation. /out specifies the output file, see: http://msdn2.microsoft.com/en-us/library/bw3t50f3.aspx For compiling source code from within an application during runtime, I would suggest to make use of the System.CodeDom.Compiler classes (e.g. System.CodeDom.Compiler.CSharpCodeProvider) for compiling C#. There's also providers for other languages, unified under the ICodeCompiler interface (see MSDN). Regards, d.mon
-
another textbox questionHm.. Maybe try to add [code]textbox.SelectionStart = 0;[/code] to the LostFocus event?
-
BinaryWriter.Write(string)For .NET users, they can simply use BinaryReader.ReadString(), that's correct. But I wanted to describe the file format for non-.NET users. I don't think they know a thing about it if I say "it's .NET prefixed". I haven't found any information on MSDN, too. :) If I just write a 127 characters string, the hex code looks like: 7F 78 78 78 78... (where 78 is 'x'), 7F = 127 For 128 characters it's: 80 01 78 78 78 78... 80 = 128, 01 = ?. For 256 characers it's: 80 02 78 78 78 78... For 300 characters it's: AC 02 78 78 78 78... For 512 characters it's: 80 04 78 78 78 78... For 32768 characters it's: 80 80 02 78 78 78... Now ok.. the 127 (and below) version looks quite simple.. but compared to the 128+ version, how can one determine if the second byte does not belong to the string but to the length prefix? I don't get the clue of this length prefixing thing :) -- modified at 12:34 Wednesday 14th December, 2005 [quote]393: while (value >= 0x80) { 394: Write((byte) (value | 0x80)); 395: value >>= 7; 396: }[/quote] Hm so.. this means, while the byte value is >= 0x80 (128) there is a following byte, as long at it's value is < 0x80. But what about the 300 characters prefix? AC 02? AC is just 172 in decimal but the string length is 300. -- modified at 12:38 Wednesday 14th December, 2005 Ah hell... wait... this prefix thing is very confusing. So.. AC means 0x80 + 0xAC = 300. Why needs that damn technique to be so complicated? ;) It makes it even more difficult to describe the length prefix :wtf:
-
BinaryWriter.Write(string)Hi. How can I determine when a length-prefixed string is prefixed with a byte (1 byte) or word (2 bytes) value? Furthermore in what format is the length-value? (fyi: it's not just the length) I stumbled upon this question when describing the format of a file. I've tested around a lot but didn't get the clue of what format the length-prefix is. Thanks for advice.
-
Are you good with Maths APIUmm.. yes, I got it out of the abyss of insanity, I'm walking quite close to it but usually don't use anything from there :D Even if it works, it's awful, but it works :D I also like the ASM version from Niklas Ulvinge :)
-
graphics.Clear(color) - Incorrect color!It doesn't sound strange to me, since RGB is a 24 bit value, even if computers like powers of 2. If no color table is used, then the 24 bit value needs to be encoded as a 16 bit color which is 5 bits for each color (red, green blue), 1 bit unused. I may be not completely right with that. E.g. a 16 bit color can be converted to a 32 bit value with:
Color32 = ( (((Color16 >> 10) & 0x1F) * 0xFF / 0x1F) | ((((Color16 >> 5) & 0x1F) * 0xFF / 0x1F) << 8) | ((( Color16 & 0x1F) * 0xFF / 0x1F) << 16));
Looks weird. A 16 bit color may look like tihs.7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 <- Bits U R R R R R G G G G G B B B B B <- Color U = Unused R = Red ...
-
RichTextBox, manipulating RTF directlyHi there. In order to create a class for a chat application - like readonly textbox that inherits the System.Windows.Forms.RichTextBox, I am trying to use a predefined color table (IRC-like textbox) in the RTF code.
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Fixedsys;}} {\colortbl ;\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue139;\red0\green100\blue0;\red255\green0\blue0;\red128\green0\blue0;\red128\green0\blue128;\red255\green165\blue0;\red255\green255\blue0;\red144\green238\blue144;\red95\green158\blue160;\red0\green255\blue255;\red0\green0\blue255;\red255\green192\blue203;\red169\green169\blue169;} "\viewkind4\uc\pard\f1\highlight1\cf2 This line uses the first color as foreground- and the second color as background-color on this line\par \highlight0\cf0 This line uses default colors.}
After I set the new RichText (control.RTF = variable), the RichTextBox automatically reformats the raw rich text I manipulated just a few ticks ago. It removes all not yet used colors from the colortable and even reorders it. Is there a way to override/avoid automatic reformatting of the raw richtext (control.RTF)? I don't want to use the techinque where the last added text is selected, some forecolor applied, via API some background color applied, ... Daniel -
Are you good with Maths APIWhile walking at the abyss of insanity, I found out, you can use something completely senseless, far away from anything that could be called useful. Evalute strings.
int x = 27; int n = 0; string seperator = System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator; double d = ((double)x / 10.0d); string s = d.ToString("F1"); if (!s.Substring(s.IndexOf(seperator) + 1, 1).Equals("0")) { d += 1.0d; s = d.ToString("F1"); } n = int.Parse(s.Substring(0, s.IndexOf(seperator)));
-
Are you good with Maths APIgee *cough* I'll join, assuming x is an int..
int n = (x / 10) + (x % 10 > 0 ? 1 : 0);
*lame around* \o/ -
How to checkText Box value is a String or Float?In a short I can only tell about the "dirty" way.. bool isFloat = false; float value = 0f; try { value = float.Parse(this.textBox4.Text, System.Globalization.NumberStyles.Float); isFloat = true; } catch { // isFloat is not set to true so it's not a float value. } By trying to parse the input text as float, you can determine wether the input is a valid float as string or not. If not, an exception will be thrown upon "float.Parse(string)" and isFloat will not be set to true. Someone correct me, if I missed something on that example *cough* :) Daniel Monzert
-
How I can use a function from another applicationAnother option at runtime: You can load a .NET Assembly at runtime. Assembly assembly = Assembly.LoadFile("app.exe"); Type type = assembly.GetType("MyApp.MyNamespace.MyClass"); object obj = Activator.CreateInstance(type); "type" may be -null- if the given type name wasn't found in the assembly. You can create an object without loading the assembly through the "Activator.CreateInstanceFrom" method. Just search for some articles on how using Assemblies that are loaded at runtime and/or the Activator class. I prefer the implementation at design time though.
-
How I can use a function from another applicationOne option is at design time: If the other application's EXE name is called 'app.exe', copy it to 'app.exe.dll' and add it as 'Reference' to your project. Right-click on "References" in the Visual Studio's Solution Explorer, choose "Add Reference..." and "Browse..." for the 'app.exe.dll' .NET tab of the dialog. If app.exe has a class "MyClass" in the namespace "MyApp.MyNamespace" you can use it in your application with "MyApp.MyNamespace.MyClass myClass = new MyApp.MyNamespace.MyClass()", for example. /EDIT: The reason for renaming the app.exe to app.exe.dll is, that Visual Studio allows only .DLL files as file references.
-
Override Items property in a list viewI don't know if you can make the ListView using m_ItemsExtra instead of the, probably, private class member it uses to list its items. Why not trying a different thing? I mean.. if I want more/own functionality in "my" ListViewItem, I'd inherit ListViewItem. public class MyListViewItem : ListViewItem I can still use it with the ListView because it is implicitly casted to ListViewItem (I guess on the implicit cast).
-
of Open FileI am not familiar with that but I doubt that c:\Windows\Assembly or c:\winnt\assembly contains any files. It is the global assembly cache, isn't it? So if you want to open an assembly, try looking in C:\WINNT\Microsoft.NET\Framework\v1.1.4322 or C:\Windows\... and the version of your choice if you installed more than one version of the .NET Framework (ie .net framework 1.0/1.1/2.0).
-
Get/SetAccessors look like this: public Point MouseCursorPosition { get { return m_MouseCursorPosition; } set { m_MouseCursorPosition = value; } } When getting a value from "MouseCursorPosition", it returns the value of the private member m_MouseCursorPosition. With accessors you can make private members to be read-only if needed. Simply leave the set accessor and only implement the get accessor. As an option you can add more code to the bodies of get/set if needed. For example.. public Bitmap Picture { get { return m_Picture; } set { m_Picture = value; RedrawBitmap(); } } .. you draw the new picture that is set. Accessors are cute :)
-
DllImport, function argument problemsHi there. I want to import a function of a simple C written DLL from within a C# project. Not that difficult... actually. But I keep getting exceptions. I spent hours for searching on the internet for articles that may help me but didn't find anything that helped me to solve my problem. This is the C code out of the header: [code]typedef struct tagHuffmanObj { int has_incomplete; int incomplete_node; char incomplete_byte; }HuffmanObj; void Compress(char *dest, const char *src, int *dest_size, int *src_size); void Decompress(char *dest, const char *src, int *dest_size, int *src_size, HuffmanObj *obj);[/code] Q1: What's the correct declaration for importing the functions? I tried different things on this, none of it worked. I keep getting NullReference exceptions but I don't know what exactly that means. Some time ago (1+ year) I read that NullReference expeptions come up upon passing wrong arguments to the function. The function in the dll is exactly compiled as given in the header, I recompiled the DLL since it's open source. public static extern void Compress(ref byte[] dest, ref byte[] source, ref int destSize, ref int srcSize); for example. I mean.. if C doesn't care about datatypes, the function would simlpy read the byte code given by dest/source with the given lengths. And I just pass it a byte array with the ascii codes. Q2: Is it correct, that the C# struct for HuffmanObj is just 2 int variables and a byte variable in the same order? Just to be sure.. I'm kinda confused on how to import the functions properly.