Click here to Skip to main content
15,911,531 members
Home / Discussions / C#
   

C#

 
GeneralRe: Typed Datasets Pin
cdpace25-Aug-09 9:13
cdpace25-Aug-09 9:13 
GeneralRe: Typed Datasets Pin
Henry Minute25-Aug-09 9:26
Henry Minute25-Aug-09 9:26 
GeneralRe: Typed Datasets Pin
cdpace25-Aug-09 11:28
cdpace25-Aug-09 11:28 
GeneralRe: Typed Datasets Pin
Henry Minute25-Aug-09 12:07
Henry Minute25-Aug-09 12:07 
GeneralRe: Typed Datasets Pin
cdpace25-Aug-09 20:37
cdpace25-Aug-09 20:37 
QuestionHow to have a "Loading..." Form Pin
shultas25-Aug-09 5:57
shultas25-Aug-09 5:57 
AnswerRe: How to have a "Loading..." Form Pin
DaveyM6925-Aug-09 6:22
professionalDaveyM6925-Aug-09 6:22 
QuestionHow to rebuild a struct from bytes after transfer [C#] Pin
Shaitan0025-Aug-09 4:46
Shaitan0025-Aug-09 4:46 
I am using Named Pipes to transfer data from a client (C++) to a server (C#), the client does the following:

[Code]
struct MESSAGE
{
char cCommand[8];
string sParameter;
};

MESSAGE msg;
strcpy(msg.cCommand, "COMMAND");
strcpy(msg.sParameter, "DO SOMETHING");

DWORD dwWrote = 0;
WriteFile (hpipe, &msg, sizeof(msg), dwWrote, NULL);
[/Code]


Then, at the receiving end the C# server does the following:
[Code]
IntPtr chRequest;
bool fSuccess = ReadFile(hPipeInst, chRequest, uSize, cbRead, OverlappedPtr);
if (fSuccess)
byte[] temp = Encoding.ASCII.GetBytes(Marshal.PtrToStringAnsi(chRequest));
[/Code]

Now, at the receiving end, I need to transform the temp (byte[]) back into the STRUCT or something equivalent so I can access the members cCommand and sPatameter - but at this point I have no clue how to proceed... In reality doesn't need to be a struct, I just need to extract the data itself.

Note - the STRUCT MESSAGE is something I came up with, meaning that it can be changed if a different format would be helpful in the reconstruction (add the length of sParameter for example?), I just need a COMMAND and PARAMETER to be transfered in a single block (if possible).

Requirements are simple:
- COMMAND is a fixed-length 8-characters long string that indicates what action needs to be performed
- PARAMETER is a variable-length (unless this causes issues) parameter dependant on each COMMAND

For example:
COMMAND = TRANS
PARAMETER = C:\FILE.txt C:\NewFolder\FILE.TXT
(this is just to illustrate, there are a lot more applications)


If possible I would like to extract it as a chunk of data (byte[]) and then pass it along to my application where it could be decomposed, not a fan of reading in the size, then a field, then a size, then a field - that requires that my Communication be overly linked with my implementation.


If there is a more suitable way to implement this transfer please let me know... advice would be welcome...
Any help would be much appreciated.
Thanks,
AnswerRe: How to rebuild a struct from bytes after transfer [C#] Pin
stancrm25-Aug-09 5:20
stancrm25-Aug-09 5:20 
AnswerRe: How to rebuild a struct from bytes after transfer [C#] Pin
DaveyM6925-Aug-09 7:24
professionalDaveyM6925-Aug-09 7:24 
QuestionCompile errors in Release mode while there are no errors in Debug mode Pin
NarVish25-Aug-09 4:38
NarVish25-Aug-09 4:38 
AnswerRe: Compile errors in Release mode while there are no errors in Debug mode Pin
Hristo-Bojilov25-Aug-09 7:07
Hristo-Bojilov25-Aug-09 7:07 
QuestionThe stream does not support concurrent I/O read or write operations Pin
mbyamukama25-Aug-09 3:38
mbyamukama25-Aug-09 3:38 
AnswerRe: The stream does not support concurrent I/O read or write operations Pin
riced25-Aug-09 6:51
riced25-Aug-09 6:51 
Question[Message Deleted] Pin
ankitjain111025-Aug-09 2:56
ankitjain111025-Aug-09 2:56 
AnswerRe: how to dispaly some specific values from databse into datagrid view...am using microsoft access Pin
Henry Minute25-Aug-09 3:01
Henry Minute25-Aug-09 3:01 
AnswerRe: how to dispaly some specific values from databse into datagrid view...am using microsoft access Pin
Vasudevan Deepak Kumar25-Aug-09 3:03
Vasudevan Deepak Kumar25-Aug-09 3:03 
AnswerRe: how to dispaly some specific values from databse into datagrid view...am using microsoft access Pin
Keith Barrow25-Aug-09 3:05
professionalKeith Barrow25-Aug-09 3:05 
AnswerRe: how to dispaly some specific values from databse into datagrid view...am using microsoft access Pin
Blue_Boy25-Aug-09 3:06
Blue_Boy25-Aug-09 3:06 
AnswerRe: how to dispaly some specific values from databse into datagrid view...am using microsoft access Pin
ankitjain111025-Aug-09 3:20
ankitjain111025-Aug-09 3:20 
QuestionC# FTP Site Creation on IIs 5.1 ( System.DirectoryServices) Pin
MikeSharp25-Aug-09 2:44
MikeSharp25-Aug-09 2:44 
AnswerRe: C# FTP Site Creation on IIs 5.1 ( System.DirectoryServices) Pin
Vasudevan Deepak Kumar25-Aug-09 3:12
Vasudevan Deepak Kumar25-Aug-09 3:12 
GeneralRe: C# FTP Site Creation on IIs 5.1 ( System.DirectoryServices) Pin
MikeSharp25-Aug-09 6:39
MikeSharp25-Aug-09 6:39 
QuestionCustomizing a Windows Form Pin
Etienne_12325-Aug-09 2:24
Etienne_12325-Aug-09 2:24 
AnswerRe: Customizing a Windows Form Pin
pelnor25-Aug-09 3:44
pelnor25-Aug-09 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.