Click here to Skip to main content
15,895,538 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to convert VC++ to C# code? Pin
momer18-Oct-04 16:51
momer18-Oct-04 16:51 
GeneralText Wrap for ListView in C# Pin
Member 141415918-Oct-04 1:09
Member 141415918-Oct-04 1:09 
GeneralRe: Text Wrap for ListView in C# Pin
Heath Stewart18-Oct-04 7:11
protectorHeath Stewart18-Oct-04 7:11 
GeneralRe: Text Wrap for ListView in C# Pin
Sundar K18-Oct-04 18:52
sussSundar K18-Oct-04 18:52 
GeneralRe: Text Wrap for ListView in C# Pin
Heath Stewart19-Oct-04 5:32
protectorHeath Stewart19-Oct-04 5:32 
GeneralRe: Text Wrap for ListView in C# Pin
Member 141415919-Oct-04 13:35
Member 141415919-Oct-04 13:35 
GeneralWebSerivce output xml Pin
jzb18-Oct-04 0:42
jzb18-Oct-04 0:42 
GeneralRe: WebSerivce output xml Pin
Heath Stewart18-Oct-04 7:04
protectorHeath Stewart18-Oct-04 7:04 
Your .NET web service client is derived from WebClientProtocol. As such, you can override GetWebResponse, save the XML, and call base.GetWebResponse. For a good design, also define a property to turn this off and on (like Debug) so that you can build a release library without a lot of code changes. Here's how I'd do it (assume implementation is in your proxy class - never update the class automatically or you'll most likely loose your changes):
// Set defaults based on release
#if DEBUG
bool debug = true;
[DefaultValue(true)]
#else
bool debug = false;
[DefaultValue(false)]
#endif
public bool Debug
{
  get { return debug; }
  set { debug = value; }
}
 
protected override void GetWebResponse(WebRequest request)
{
  WebResponse response = base.GetWebResponse(request);
  SaveResponse(response);
  return response;
}
 
protected override void GetWebResponse(WebRequest request, IAsyncResult result)
{
  WebResponse response = base.GetWebResponse(request, result);
  SaveResponse(response);
  return response;
}
 
void SaveResponse(WebResponse response)
{
  if (!Debug) return;
 
  using (FileStream file = new FileStream("response.xml", FileMode.Create,
    FileAccess.Write, FileShare.Read))
  {
    int read = 0;
    byte[] buffer = new byte[4096];
    Stream s = response.GetResponseStream();
 
    while ((read = s.Read(buffer, 0, buffer.Length)) > 0)
      file.Write(buffer, 0, read);
  }
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralTreeView DragDrop image Pin
dorothyDorothy17-Oct-04 23:39
dorothyDorothy17-Oct-04 23:39 
GeneralRe: TreeView DragDrop image Pin
Heath Stewart18-Oct-04 6:52
protectorHeath Stewart18-Oct-04 6:52 
GeneraldateTime parser Pin
Rob Tomson17-Oct-04 23:27
Rob Tomson17-Oct-04 23:27 
GeneralRe: dateTime parser Pin
J4amieC18-Oct-04 0:28
J4amieC18-Oct-04 0:28 
GeneralTreeView/ListView item selection and context menu Pin
EnkelIk17-Oct-04 21:44
EnkelIk17-Oct-04 21:44 
GeneralRe: TreeView/ListView item selection and context menu Pin
petst17-Oct-04 22:06
petst17-Oct-04 22:06 
GeneralRe: TreeView/ListView item selection and context menu Pin
afinnell18-Oct-04 5:35
afinnell18-Oct-04 5:35 
GeneralRe: TreeView/ListView item selection and context menu Pin
Heath Stewart18-Oct-04 6:41
protectorHeath Stewart18-Oct-04 6:41 
Generalcapturing any window in ur application Pin
Member 143169617-Oct-04 21:18
Member 143169617-Oct-04 21:18 
GeneralRe: capturing any window in ur application Pin
Heath Stewart18-Oct-04 6:32
protectorHeath Stewart18-Oct-04 6:32 
GeneralSending a string to Crystal Report Pin
myNameIsRon17-Oct-04 21:06
myNameIsRon17-Oct-04 21:06 
GeneralRe: trying to write to a log file in destructor Pin
Colin Angus Mackay17-Oct-04 20:56
Colin Angus Mackay17-Oct-04 20:56 
GeneralRe: trying to write to a log file in destructor Pin
Gavin Jeffrey17-Oct-04 21:41
Gavin Jeffrey17-Oct-04 21:41 
GeneralRe: trying to write to a log file in destructor Pin
Colin Angus Mackay17-Oct-04 23:01
Colin Angus Mackay17-Oct-04 23:01 
GeneralGetting all the section names from an ini file Pin
Member 64506717-Oct-04 20:32
Member 64506717-Oct-04 20:32 
GeneralRe: Getting all the section names from an ini file Pin
Colin Angus Mackay17-Oct-04 20:50
Colin Angus Mackay17-Oct-04 20:50 
GeneralRe: Getting all the section names from an ini file Pin
Heath Stewart18-Oct-04 6:28
protectorHeath Stewart18-Oct-04 6:28 

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.