|
overbored wrote:
string and String?
nothing Same as int = Int32, short = Int16 , bool = Boolean, etc. MSDN defines them as aliases.
overbored wrote:
casting a value using (string) and using ToString()?
The ToString() method allow programmers to have a friendly text definition of an object. EG font.ToString() will return all the font's parameters, name, etc. Purely informational, where a (string) object wont be allowed unless the object is a string or a string cast has been implemented (not sure on how you would do this).
Hope this helps
READ MSDN
|
|
|
|
|
leppie wrote:
Purely informational, where a (string) object wont be allowed unless the object is a string or a string cast has been implemented (not sure on how you would do this).
You can do this with the implicit and explicit operators. Here is a small bit of code that will allow a class to be implicitly cast to a string.
<br />
public static implicit operator string(MyClass c) {<br />
return c.ToString();<br />
}<br />
This will allow for the implicit conversion of MyClass to a string. If you want to force people to explicitly cast to a String then change the keyword to explicit instead of implicit
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
String mostly used in ASP.NET I think.And convert to string there.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I am making a download class, kinda ambitious, considering I know little, but, at the moment, it supports paused/resume downloads, and saving the state of the downloads, so the program ccan be shut down, and the downloads will carry on when iots started up again. anyway, i am trying to add support for multiple downlioad locations, and i want to be able to generate a checksum, or something, for the remote file, and the local file, so that i can verify if the file was downloaded successfully, but i do not know how, any help, or pointers in the right direction?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
i want to be able to generate a checksum, or something, for the remote file,
Thats not really possible unless you own the internet
I assume you want somethin similar to eDonkey's file hashing to prevent corrupted downloads. Unless you can control the other side, you cant get a checksum.
I also presume you want somethin similar to GetRight's Segmented downloading. Most programs doing this, creates a blank file to the size (from the returned HTTP header) of the downloaded file, then writes to the file byte by byte.
You can easily run a "scan" thru the file to see what is still needed. Also by changing the header sent u can resume most files if the server supports partial content (see below).
Nnamdi Onyeyiri wrote:
i am trying to add support for multiple downlioad locations
In your your Download class change the "URL" property to URL[]. Or if you dont have somethin like that, you might want to create it to keep track of other variables like speed, pingtime and availability. Also note that you will need to make sure each download location has exactly the "same" file by comparing the sizes. Also , you need to make sure that the remote file's date hasnt changed (incase file size is the same) when resuming the download, although some servers might create the file on the fly to prevent leeching
Hope this all helps
Example of header sent for partial content:
!!!! ----Header Sent----
>>>> GET /Downloads/MagicInstall.msi HTTP/1.1
Host: www.dotnetmagic.com
Range: bytes=23232-
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)
Accept: */*
If-Range: Fri, 12 Jul 2002 18:28:00 GMT
Example of header recieved for partial content:
!!!! ----Header Recv----
HTTP/1.1 206 Partial Content
Date: Wed, 17 Jul 2002 08:19:38 GMT
Server: Apache
Last-Modified: Fri, 12 Jul 2002 18:28:00 GMT
ETag: "1441e9-8b600-3d2f1fb0"
Accept-Ranges: bytes
Content-Length: 547648
Content-Range: bytes 23232-570879/570880
Content-Type: text/plain
READ MSDN
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
i was not sure how to get them all to write to the same file at once.
Try referencing them all to the same filestream, you will be writing a byte buffer (say 4kb) at any one time, using a lock to prevent (or rather queue) the other threads from writing to the stream at the same time.
READ MSDN
|
|
|
|
|
|
the byte buffer will be written to the file sequencially , you will just need to keep track of the start offset where it should be written in the file for each thread
READ MSDN
|
|
|
|
|
|
If got problems, send me the source as I just created a need to have a class like that as well
Cheers
Good Luck
READ MSDN
|
|
|
|
|
leppie wrote:
If got problems, send me the source as I just created a need to have a class like that as well
a download class?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Yes , something that I want to integtrate into an IRC client i am writing.
READ MSDN
|
|
|
|
|
im not writing a program per say, more of im just writing misc classes, and putting them into a dll, for use in future projects.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Thats what i meant Then I wont have to write it and I can maybe help you better it if neccesary
I am almost 80% complete with my IRC client and HTTP transfer is one of the funtionalities I would like to implement as a plugin to my client, as well as FTP and some file sharing protocols.
Give me a shout then when done please
Cheers
READ MSDN
|
|
|
|
|
|
All...
I've written a windows service which works properly on my development machine and on a QA machine. When installing it on a production machine,the service tries to start however after waiting about 30 seconds, it stops and SCM gives an error that the service did not respond in a timely fashion.
I've gone back to my code and commented everything except for a static logging method that I'm using for debugging. The entry point code is listed below...when starting the service, it is failing between logging the 2nd /3rd lines. Keep in mind that all code is commented out in the "transportClass" at this point and it is still failing to start the service. Given that it works beautifully on multiple other machines, I think it must
be configuration of some sort -- any thoughts???
/*******************************
static void Main()
{
LogError("Starting Main");
System.ServiceProcess.ServiceBase[] ServicesToRun;
LogError("Second Line");
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
transportClass() };
LogError("Third Line");
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
LogError("Exiting Main");
}
*******************************/
Thanks,
Jason Mark
jmark@comcenters.com
|
|
|
|
|
I have added a custom component that draws a big ellipse on a form. (It's much more involved, but keeping it easy for an example)
Inside of the initialization, I add a delegate to the Form's Paint method.
m_Parent.Paint += new PaintEventHandler( this.Paint );
Unfortunately, the delegates are drawn first, and then all of the controls. So, all of the controls are drawn on top of my ellipse and I can't see it.
Since there isn't a method called Painted , how can I get my component to draw on TOP of the other controls instead of on the bottom?!
|
|
|
|
|
You could try using:
<br />
this.Invalidate();<br />
Call this after everything else has been drawn. The invalidate method causes the control to repaint itself. You may need to remove the handler that you gave in your post. I think this should work, but I can't be sure.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Hello everyone,
I have been sifting through code project to find an answer to my question and I came up with with an article about how to make calls to the windows API with C# but it didn't quite answer my problem. How would I make a call to the Window API to change the screen resolution? What would be the call to play sound files (From what I've seen .NET doesnt have any functions to play sound files)?
|
|
|
|
|
You would use a call to ChangeDisplaySettings.
This might help:
class Win
{
internal const int ENUM_CURRENT_SETTINGS = -1;
internal const uint DM_BITSPERPEL = 0x00040000;
internal const uint DM_PELSWIDTH = 0x00080000;
internal const uint DM_PELSHEIGHT = 0x00100000;
internal const uint DM_DISPLAYFREQUENCY = 0x00400000;
internal const int CDS_UPDATEREGISTRY = 0x00000001;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal class DEVMODE
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
internal string dmDeviceName;
internal ushort dmSpecVersion;
internal ushort dmDriverVersion;
internal ushort dmSize;
internal ushort dmDriverExtra;
internal uint dmFields;
internal short dmOrientation;
internal short dmPaperSize;
internal short dmPaperLength;
internal short dmPaperWidth;
internal short dmScale;
internal short dmCopies;
internal short dmDefaultSource;
internal short dmPrintQuality;
internal short dmColor;
internal short dmDuplex;
internal short dmYResolution;
internal short dmTTOption;
internal short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
internal string dmFormName;
internal ushort dmLogPixels;
internal uint dmBitsPerPel;
internal uint dmPelsWidth;
internal uint dmPelsHeight;
internal uint dmDisplayFlags;
internal uint dmDisplayFrequency;
internal uint dmICMMethod;
internal uint dmICMIntent;
internal uint dmMediaType;
internal uint dmDitherType;
internal uint dmReserved1;
internal uint dmReserved2;
internal uint dmPanningWidth;
internal uint dmPanningHeight;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, [In, Out] DEVMODE lpDevMode);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern int ChangeDisplaySettings(DEVMODE lpDevMode, int dwFlags);
}
|
|
|
|
|
Thank you
|
|
|
|
|
Defeats the portability of the application?
Normski. - the next bit of code is self modifying ... jmp 0xCODE
|
|
|
|
|
I have 10 different assembilies, I want to put it in One Library file or one assembly, cause I don't want to add references upto 10 times everytime for my different screen. Is anybody know how to do that.
Thanks in advance
|
|
|
|
|
Try putting them all in one project.
|
|
|
|