|
Hi,
I don't have very specific answers, however:
1. I'm pretty sure it can all be done programmatically.
2. You will have to provide more than one resolution (all square, and multiples of 16). Windows will use different icons on different occasions (Windows Explorer, large icon/small icon; taskbar buttons; desktop shortcuts; etc); and it differs for different Windows editions (typically newer editions such as Vista/Win7 like to also have larger icons, up to 96*96).
|
|
|
|
|
I need to get an image from the system clipboard (Clipboard.GetImage()) and serialize it to a file. The end goal would be to, at a later time, deserialize this image and put it back in the clipboard.
I can't figure out how to successfully serialize the image. I tried creating a serializeable class that contains an image object, but I get the exception
"The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
I tried using XmlInclude but am either doing it wrong or it does not resolve the problem.
Has someone done this before?
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
|
Please avoid cross-posting questions across forums. You don't need to waste the time of one of the people trying to answer your question after somebody else has already answered it.
|
|
|
|
|
So you're saving an image as XML?
This is why we need 1TB+ harddisks these days.
|
|
|
|
|
Hi , have a good day
When I want to output some result to console, from a Windows Application ( GUI )
I do this :
Project -> Project Properties -> Application -> Output Type: "Console Application"
int a = 17.5;
int b =5;
a= a * b;
datagridview1.DataSource = datatable;
Console.WriteLine(datagridview1.Rows.Count);
Console.WriteLine(a);
Thank you
I know nothing , I know nothing ...
|
|
|
|
|
Very illuminating. Now, why did you post that?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
And your question is...?
I prefer to attach a console like this[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Thank you , I learned something new
I know nothing , I know nothing ...
|
|
|
|
|
|
I'm doing some work with Active Directory using C# and the DirectoryEntry object. I'm fairly new to C# and exceptions, go easy on me!
Some Code:
DirectoryEntry entry = new DirectoryEntry ( LDAPServer, domainAndUsername, Password );
try
{
Object obj = entry.NativeObject;
}
catch (Exception ex)
{
ErrorMessage = ex.Message;
return false;
}
Now, it seems that when binding to the DirectoryEntry fails, the exception is called. The error is returned as a string, which gives me an idea as to what happened, But how do I test what the error was programmatically? Is there some kind of numeric value as well in the exception that I can test?
Basically, I want to know if the connection failed because of a bad ldapserver, or a username/password mismatch etc. I'm trying to create code that does a fail-over to a second ldap server if the primary ldap server is offline. I don't want to jump to the second server to retry the authentication, if there was an error with the credentials.
Is there another exception I can test for here? How would I found out what other exceptions are available for this object?
Any help you could give would be great.. Heck, I'll buy you a beer!
Mike
|
|
|
|
|
One way to do this is to have a series of catch blocks.
try
{
Object obj = entry.NativeObject;
}
catch (System.UnauthorizedAccessException e)
{
MethodToDealWithThisTypeOfError(aParameterFromEventArgs, anotherParameter);
return false;
}
catch (System.DivideByZeroError e)
{
MethodToDealWithThisTypeOfError(aParameterFromEventArgs, anotherParameter);
return false;
}
finally
{
MeassageBox.Show("This happens regardless of errors", Application.ProductName);
}
and so on.
[Edit]
Here is a reasonable article[^]
[/Edit]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I am able to extract the text from the PDF file using the PDFStripper, but I would like to read the Table of content of the PDF document. How can I do that? How do I know the Page I am reading is Table of Contents? and also how to differentiate the Chapter heading and the subsection of chapter of the Table of Content?
Any help in this is highly appreciated.
Thanks
Neil
|
|
|
|
|
Your best source of information is the people who wrote PDFStripper, but I think some of this would be subject to how the PDF is organized and written.
If PDFStripper doesn't provide any data to differentiate this, you'd have to implement logic (probably fuzzy) to try and analyze a page to see if it MAY be a TOC. The problem would be determining where the TOC ends.
You've got the same problem for the other parts of the document you want to pull out.
|
|
|
|
|
Hi there,
in an application which I developed on a Windows XP computer in Visual Studio 2005 Express with C#, I set a tooltip in a MouseMove event of a panel. On that environment, everything looks fine.
Then I loaded the source code on a Windows 7 64 bit computer in Visual Studio 2005 Professional, started the application, and found that the tooltip was terribly flickering, even when I did not move the mouse.
I added variables for storing the last mouse position, and in the MouseMove event I leave now the function when the position has not changed. Now the tooltip looks fine on Win7 also.
For debugging purposes, I set a break point on that return statement, I really get there...
I.e. a MouseMove event is fired though the mouse is not moving.
What are your experiences with MouseMove and tooltips with respect to Windows 7? Looking forward to your statement.
Regards,
Bernhard
|
|
|
|
|
I just had the exact same experience with tooltip flickering inside of a DataGridView. This flicker was also found only on Windows 7 and not on XP and was caused by the MouseMove event firing repeatedly in Windows 7 when the mouse is not moving.
For now I have applied your same fix. If I find the underlying cause I will try to follow up.
Jason
|
|
|
|
|
Thanks it helped me too 
|
|
|
|
|
hi, I'm using the below code for my client/server application.The question is, it creates a new connection each time it triggered by the timer and the number of sockets in the arraylist(alSockets) increases. What is the ideal way?
if you don't mind, I have another question;
if a client is sending two requests, server has to reply those two requests. If server replies only one instead of two, an exception is thrown. Sometimes I may need to send three requests, how can I prepare the server so that no exception is thrown
public void listenerThread()
{
IPHost = Dns.GetHostEntry(Dns.GetHostName());
TcpListener tcpListener = new TcpListener(IPHost.AddressList[0], 8080);
tcpListener.Start();
while (true)
{
Socket listenerSocket = tcpListener.AcceptSocket();
if (listenerSocket.Connected)
{
lock (this)
{
alSockets.Add(listenerSocket);
}
Thread thdHandler = new Thread(new ThreadStart(handlerThread));
thdHandler.Start();
}
}
}
public void handlerThread()
{
Socket handlerSocket = (Socket)alSockets[alSockets.Count - 1];
NetworkStream networkStream = new NetworkStream(handlerSocket);
ntrStream = new NetworkStream(handlerSocket);
strRead = new StreamReader(ntrStream);
strWrite = new StreamWriter(ntrStream);
string textFromClient = strRead.ReadLine();
if (handlerSocket.Connected)
{
}
}
private void timer1_Tick(object sender, EventArgs e)
{
connectToServer();
}
private void connectToServer()
{
IPHostEntry ipHost = Dns.GetHostEntry(server);
try
{
client = new TcpClient(ipHost.AddressList[0].ToString(), 8080);
ntrStream = client.GetStream();
streamWrite = new StreamWriter(ntrStream);
streamYaz.WriteLine("textToServer");
streamYaz.Flush();
ntrStream.Close();
streamWrite.Close();
}
catch (Exception)
{
MessageBox.Show("No Connection");
}
}
|
|
|
|
|
If you're just using alSockets to get a reference to the latest collection, then you can eliminate that entirely.
Give handlerThread an object parameter, and call it as a ParameterizedThreadStart (Check the overloads for the Thread constructor). That way, you can pass the socket itself as a parameter, and avoid the potential race condition.
teknolog123 wrote: if you don't mind, I have another question;
if a client is sending two requests, server has to reply those two requests. If server replies only one instead of two, an exception is thrown. Sometimes I may need to send three requests, how can I prepare the server so that no exception is thrown
Usually you create some sort of communication protocol that both the server and client adhere to. Just make sure the server replies to each message in turn... Not really sure what the problem is here.
|
|
|
|
|
thanks for your reply,
Ian Shlasko wrote: Not really sure what the problem is here.
to be more specific, Client is sending three messages. Server is prepared for replying those three messages.If sometimes client sends four messages, how can I prepare my server to accept that fourth message without exception error?
I'm sorry if I'm not clear enough
|
|
|
|
|
Well, you're going to have to be clearer... Why does it matter if the client sends three messages, four, or four hundred? The server should receive the messages, respond to it, and wait for the next one.
|
|
|
|
|
Hi Guys. How can I check if a file is being used by another process?
I have tried the following but it doesn't seem to work though.
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
If I open the .txt file in NotePad and then run the app it opens the file. What I need to do is for my app to throw an exception that tells me that the file being used by another process , or something like that.
Anybody have any idea?
Thanks
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
I'm not sure you can. Notepad Opens the file, reads the content, and closes it again. It may never touch the file again, so how is the OS to know the file is "in use"?
If you think about it, most well behaved applications do much the same - file handles are a scarce resource, so you don't hang onto them unless you really must.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
There's no way to tell. Notepad doesn't hold the file open while you are viewing it. It's opened, read, and closed before you even see it on screen. Notepad also doesn't block other applications from reading the file at the same time it is, so this code will fail to detect Notepad using the file in all cases.
|
|
|
|
|
Try opening this file in MS Word. It locks the file when you open it.
Then when you open file, test your application.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|