|
Thanks alot for the help =D
It solved my problem and i understand now why it dident work before=)
Best Regards
Jimmy
|
|
|
|
|
Hello all,
I am new to C# and I need to be able to cast from a byte array to a struct. What is the best approach to map the bytes into my structure?
I have:
struct Record
{
char a;
char b;
char c;
}
I want to be able to do this:
string myString = "123";
byte[] myData = System.Text.Encoding.ASCII.GetBytes(myString);
Record myRecord = (Record)myData;
Thanks in advance
|
|
|
|
|
Look at the Marshal class
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Is it possible to create a new dBASE IV .dbf (one that does not already exist) using C#?
Mark Sanders
sanderssolutions.com
|
|
|
|
|
For those who are interested...
string columnString = "NAME varchar(50), NUMBER int";
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + directory + ";Extended Properties=dBase IV";
string sqlString = "CREATE TABLE " + tableName + " (" + columnString + ")";
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbCommand command = new OleDbCommand(sqlString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
command.Connection.Close();
Mark Sanders
sanderssolutions.com
|
|
|
|
|
Hi All,
Does anybody know the way, how to change datagrid scrollbars style into flat, similiar to MFC CListCtrl pmyListCtrl->SetExtendedStyle(pmyListCtrl->GetExtendedStyle()|LVS_EX_FLATSB); ?
Best Regards
|
|
|
|
|
in a pictureBox.Image, i put an picture by using memoryStream from a dataset connected to Sql Server.
when i navigate by a scrollBar from one record to another, picture is well displayed in the control
(setting to null value if no image in datarow, or reading memorystream if present)
if i modify picture by paste a new image or by reading a disk picture, saving it to another memorystream (or direct to disk also) by using image.save(stream,ImageFormat.xxx) or Image.Save("filename") is OK
but if i DON'T change picturebox.image and try an Image.Save() i get this :
System.InteropServices.ExternalException
generic error in GDI +
image length is zero kByte on disk (not writing) or corrupted in memoryStream...
I don't understand !!
an Idea ?? thanks
Bruno Ferec (bferec@eni-consulting.fr)
Technical manager
|
|
|
|
|
While working on an Image Processing App I encountered the same kind of
generic error while using the Bitmap.Save() method. I did some searches in the www and it turns out that the Image/Bitmap class uses some type of on-demand loading scheme that requires the file to be open all through the object's life (therefore minimizing the amount of memory being used by big images)
This creates several problems. For instance, when you call the Image.Save("filename") to save the image to same file from where it was loaded, your program crashes because it is trying to overwrite an open file.
One workaround for this would be to save the changes to another file or to use unmanaged code to load all the image to memory.
|
|
|
|
|
There is a much simpler solution.
// Create a memory stream
MemoryStream mStream = new MemoryStream();
// Save the image to the memory stream
Image.Save(mStream, ...);
// Then write the buffer to a file.
fileStream.Write(mStream.GetBytes(), 0, mStream.Length);
I'm doing this off the top of my head, so the syntax may be slightly off, but the concept is solid. I use it all the time.
Thanks,
Steven
|
|
|
|
|
Yes, I have also used that technique of caching the Bitmap in a memoryStream. You can then dispose the bitmap object and work only with the memoryStream.
The only problem is that when working with large images (as was the case of my image processing program) this imposes a great cost in terms of memory:
1. All the bitmap info is in memory
2.Each time you want to display your bitmap in the screen you have to do something like pictureBox1.Image=Bitmap.FromStream(mStream,...)
So this is only a solution if the user has a lot of free memory or if the images he is working with are small.
|
|
|
|
|
Hi,
I'm developping two projects which share a common library. No problem.
The problem is that I would like to keep a library version, to know which features it has, but I would like that both using projects share this library (only one) without considering the version number. I mean, I would like that GAC doesn't exist!
What am I doing wrong?, what should I do?
Thanks in advance,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Just remove the file from the GAC (windir\Assembly i think) And reference the file from a common location
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
By the time Im done processing some data from a socket i received on, 2 or more packets have been received and are in the queue/buffer. When I call receive it returns all bytes as in all the packets waiting into the byte array.
Is there anyway to just receive one of those packets??... they are of all different length. I think i could just send the length of the packet as the first 4 bytes (Int32) and read in 4 bytes determine the length and then read that many, but i would think there may be a way to just ask the socket to only fill the byte array with the first packet in the queue??
Its TCP all blocking sockets.
Any help would be appreciated, i realize i could fix my problem by doing what i mentioned above (sending the length at the front, first 4 bytes), but it seems there should be a better way??
|
|
|
|
|
I would like to store data in a XML File and show the data in format like the .NET Help Documentation. Have I to design a lot of HTML Pages or is it possible to show XML data easy as a WebPage? Are there special .NET classes? Which?
How to do this? What's the way to get on to it?
Thanks
Stefan
|
|
|
|
|
I want to read a date string from a log file it is in this format ...
17/Apr/2003:06:40:39 +1000
I would like to parse this then display it as the local time format.
I am lost in the world of Globalization
James McCutcheon
|
|
|
|
|
Found my own solution ... in case anybody else wants to know:
activitytime = "01/Apr/2003:11:01:02 +1000";
DateTime dt = DateTime.ParseExact(activitytime, "dd/MMM/yyyy:HH:mm:ss zzz", new System.Globalization.DateTimeFormatInfo());
|
|
|
|
|
James McCutcheon wrote:
Found my own solution ... in case anybody else wants to know:
I always appreciate people posting their solutions if they find them. Then if someone else with the same problem comes across the same problem and finds your post, they can know the solution, too.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
I have created the following class:
public class Mobile : IDisposable
{
private TcpListener tcpListener
public Socket sockToClient
}
public Mobile (string Remote_Ep)
{
IPHostEntry hoen = Dns.Resolve(Remote_Ep);
IPEndPoint ep = new IPEndPoint(hoen.AddressList[0], 11000);
tcpListener = new TcpListener(ep);
tcpListener.Start();
Thread t = new Thread( new ThreadStart(thread_proc_IO) );
t.Start();
}
private void thread_proc_IO()
{
bool fDone = false;
while( !fDone )
{
try
{
Console.Write("\n[tid {0}]: Listening on port {1}", GetCurrThread.id(), mb_frs_port );
sockToClient = tcpListener.AcceptSocket(); // @@@
if( sockToClient.Connected )
{
Console.Write("\n[tid {0}] Client connected", GetCurrThread.id());
ClientHandler Handler = new ClientHandler(sockToClient);
Handler.StartRead();
}
}
catch (Exception ex)
{
Console.Write( "\nMobile.thread_proc_IO: [tid {0}] Exception in I/O thread - exiting. " + ex.Message, GetCurrThread.id() );
fDone = true;
}
}
}
I am creating several instances of this class, and adds every instance to ArrayList.
When I am trying to remove one of the instances, removing it from the ArrayList is not enough
I am trying to use dispose, sockToClient_dbg.Shutdown(SocketShutdown.Both), sockToClient.Close(), tcpListener.Stop() but nothing seem to work.
I also read about this bug located at www.dotnet247.com/247reference/msgs/1/8442.aspx :
"The TCPClient has some known bugs. One of them is that a TCP-connection is
NOT closed - when you call .Close(), .Dispose() method. I spent a long time figuring this out. I used Sockets instead at it all worked perfectly...."
Does anyone has any idea how to kill this socket ?
|
|
|
|
|
I'm a java programmer and am learning C# and liking it. In java I was able to create custom renderers that I could use to display a panel with a bunch of labels adn text boxes and pictures in a single slot in a list.
I want to do the same thing in c#. I want to create a class that is a panel and will contain a couple textboxes and labels. I want all this to be shown when I add it to the listbox, not the tostring method to be called and the text to be displayed. So I'm pretty much looking for a way to display a panel in a listbox slot.
If anybody has an example, advice, a better solution, or knows if this is even possible please post.
I'll continue my searching of the web and experimenting.
Thanks
Bryan
|
|
|
|
|
I think you can create your own drawing handler class that implements a certain interface and assign that to the listview's CustomDrawHandler property.
I probably should check before "sending you on a wild goose chase".
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hi,
I am pretty new to C# and VS.NET, and I need to use a Webform with textboxes where I send values to/from an Access database. I am not sure what I need to use of the following: OleDbDataAdapter/OleDbConnection/DataSet/OleDbCommand?!
How do I directly send a textfield from the webform into the access database form? Any tips/resources please?
Trond Borg.
|
|
|
|
|
// This connection string is off the top of my head, i know its wrong but kind of it, check
// www.connectionstrings.com and click on access oledb for the right one.
OleDbConnection conn = OleDbConnection( "Provider=Microsoft Jet 4.0";Data Source=C:\\db.mdb;User=peter;Password=cat" );
OleDbCommand comm = new OleDbComm( "", conn );
comm.CommandText = "UPDATE [tableName] SET ( [columnName] = " + textbox.Text + " ) WHERE ( [columnName2] = 'ID' );" ;
conn.Open();
comm.ExecuteNonQuery(); // i think this is the method name, should be obvious with auto-complete
conn.Close();
you said: "into the access database form" hope you mean table, into a form i dont think u could, have no idea.
|
|
|
|
|
I would like to convert a DateTime to double.... How I can do that?
I wanted to use Convert.ToDouble(DateTime) but is not supported yet and I receive a invalidcastexception.
Thanks!
|
|
|
|
|
What about getting the Ticks from the DateTime and converting that to a double. Is that what you need?
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
I am currently trying to get a combo box to select by default a value that I have recieved in a constructor from another form. I have tried everything that I can think of. I am sorry I feel like this is one of those easy questions but just cannot find the answer. If any one has any suggestions I would be greatly appreciated.
Thanks
Corey Embry
at first I tried this
ItemLoc = cbxManufacturer.FindString(MfgName);
cbxManufacturer.SelectedIndex = ItemLoc;
Then I tried this
cbxManufacturer.SelectedItem = MfgName;
then I tried this
cbxManufacturer.SelectedText = MfgName;
and finally I tried this
cbxManufacturer.SelectedValue = "2";
I am just plain out of ideas so if anyone can help I would be very greatful.
|
|
|
|