Click here to Skip to main content
15,893,508 members
Home / Discussions / C#
   

C#

 
GeneralRe: Writing an array list to a txt file Pin
LCI14-May-07 4:05
LCI14-May-07 4:05 
Questionbackgroundcolor for MenuItem Pin
Bekjong14-May-07 3:49
Bekjong14-May-07 3:49 
AnswerRe: backgroundcolor for MenuItem Pin
Ed.Poore14-May-07 6:16
Ed.Poore14-May-07 6:16 
GeneralRe: backgroundcolor for MenuItem Pin
Bekjong15-May-07 3:53
Bekjong15-May-07 3:53 
QuestionHelp regarding Ms Access Pin
anu8114-May-07 3:40
anu8114-May-07 3:40 
AnswerRe: Help regarding Ms Access Pin
Muhammad Gouda14-May-07 3:59
Muhammad Gouda14-May-07 3:59 
QuestionAPI in C# the func WRITE FILE Pin
barak16048714-May-07 3:28
barak16048714-May-07 3:28 
AnswerRe: API in C# the func WRITE FILE Pin
Luc Pattyn14-May-07 3:55
sitebuilderLuc Pattyn14-May-07 3:55 
Hi,

this is an example that writes a text string to a pipe using WriteFile.
For P/Invoke you can have several prototypes with different sets of arguments;
there is no need to convert to IntPtr yourself.
BTW if you provide a string or StringBuilder it will convert Unicode to 8-bit ASCII
by default.
private void SendString(StringBuilder sb) {
	IntPtr pipe2=CreateFile(pipeName, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
	Thread.Sleep(200);
	int count;
	bool OK=WriteFile(pipe2, sb, sb.Length, out count, 0);
	if (!OK) ... report error
	ClosePipe(pipe2);
}

// Writes data to a file at the position specified by the file pointer.
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool WriteFile(
	IntPtr hHandle,				// handle to file
	StringBuilder lpBuffer,			// data buffer
	int nNumberOfBytesToWrite,		// number of bytes to write
	out int lpNumberOfBytesWritten,		// number of bytes written
	uint lpOverlapped			// overlapped buffer
);


Smile | :)



Luc Pattyn

[My Articles]

QuestionWeb Services question Pin
LCI14-May-07 1:56
LCI14-May-07 1:56 
AnswerRe: Web Services question Pin
Panchal Hardik14-May-07 2:08
Panchal Hardik14-May-07 2:08 
GeneralRe: Web Services question Pin
LCI14-May-07 2:13
LCI14-May-07 2:13 
GeneralRe: Web Services question Pin
Panchal Hardik14-May-07 2:21
Panchal Hardik14-May-07 2:21 
GeneralRe: Web Services question Pin
LCI14-May-07 2:25
LCI14-May-07 2:25 
GeneralRe: Web Services question Pin
Panchal Hardik14-May-07 2:47
Panchal Hardik14-May-07 2:47 
Questionthumbnail view of a html file Pin
jazeelkm14-May-07 1:49
jazeelkm14-May-07 1:49 
AnswerRe: thumbnail view of a html file Pin
Giorgi Dalakishvili14-May-07 2:10
mentorGiorgi Dalakishvili14-May-07 2:10 
QuestionRe: thumbnail view of a html file Pin
jazeelkm14-May-07 2:21
jazeelkm14-May-07 2:21 
AnswerRe: thumbnail view of a html file Pin
Giorgi Dalakishvili14-May-07 2:29
mentorGiorgi Dalakishvili14-May-07 2:29 
QuestionRe: thumbnail view of a html file Pin
jazeelkm14-May-07 2:35
jazeelkm14-May-07 2:35 
AnswerRe: thumbnail view of a html file Pin
Giorgi Dalakishvili14-May-07 2:39
mentorGiorgi Dalakishvili14-May-07 2:39 
AnswerRe: thumbnail view of a html file Pin
jazeelkm14-May-07 2:43
jazeelkm14-May-07 2:43 
GeneralRe: thumbnail view of a html file [modified] Pin
Giorgi Dalakishvili14-May-07 2:49
mentorGiorgi Dalakishvili14-May-07 2:49 
QuestionOpen File DIalog Pin
mihksoft14-May-07 1:45
mihksoft14-May-07 1:45 
QuestionHow to Read a specific frame of WebBrowser's DocumentText Pin
Bajrang Singh14-May-07 1:22
Bajrang Singh14-May-07 1:22 
QuestionHow To Protect Viewing File Without Login using File Server Pin
attalurisubbu14-May-07 0:56
attalurisubbu14-May-07 0:56 

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.