forms equivalent of response

  • Thread starter Thread starter Craig.Wallace
  • Start date Start date
C

Craig.Wallace

Hi,

I am generally a C# web developer but find myself having to do some
windows forms work. Can anyone tell me the equivalent of
HttpContext.Current.Response for windows forms? I need to send the
user a file on button click.

Thanks,

Craig
 
Hi,

I am generally a C# web developer but find myself having to do some
windows forms work. Can anyone tell me the equivalent of
HttpContext.Current.Response for windows forms? I need to send the
user a file on button click.

Thanks,

Craig

Hi Craig,

If by "sending the user a file" you mean save to disk, you typically open a
SaveFileDialog and let the user chose a path and filename. Once the user
submits a name (DialogResult == DialogResult.OK) you then use the
SaveFileDialog.FileName property and create a new file with this name, using
System.IO classes. File.AppendAllText(SaveFileDialog.FileName", stringdata")
is a very easy way to save text to file.
 
Hi,

I am generally a C# web developer but find myself having to do some
windows forms work.  Can anyone tell me the equivalent of
HttpContext.Current.Response for windows forms?  I need to send the
user a file on button click.

Thanks,

Craig

To be precise, there is no eqivalent of global application pool class
in Windows Forms, comparing to ASP.NET, moreover it has absolutely
differernt model of user interaction, so you can expect STA model in
action, that means, that you can interact only with controls created
in current thread, so if you create another Windows Forms Control in
another thread you cannot interact with it from other thread except
those where construction of controls is to be called.

This is called Single-Thread Apartment Model. ASP.NET uses MTA model
(actually, web developer does not know, in which thread his control is
to be executed, because this doesn't matters).

Another part is Events. You can always use direct call model, it does
not need to use global variables and HttpContext.Responce.Write
methods to store/load states on an application, if it were, because
you can always raise an event on a client. Garanteed. Actual sttate of
an application is always current state of an application. Application
almost always has only one instance (overwise it is a advanced/
challenging programming part) in system. No web farms, no HTTP hell,
no browsers (except WPF Browser apps and Silverlight), no AJAX, no
REST, so, for the Web developers, some things are much simplier than
before, if you are going to program Windows Forms. Windows Forms has
its own hell: DLL (i'e' rule: "Use Global Assembly cache at least for
assemblies, you WILL NEVER change").

Good Luck!
 
Hi,

I am generally a C# web developer but find myself having to do some
windows forms work.  Can anyone tell me the equivalent of
HttpContext.Current.Response for windows forms?  I need to send the
user a file on button click.

Thanks,

Craig

Send it from where?

In a windows form app all you have to do is using the SaveFileDialog
class
 
Back
Top