Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to upload a file dynamically in windows form application
Posted
Comments
Sergey Alexandrovich Kryukov 21-Jun-12 1:03am    
Where to? To the HTTP site, FTP site? anything else?
--SA

There is no "just upload". It all depends what do you have on the server side; it should run appropriate service. In case of Web applications, is should have the upload page and be ready to accept uploads, process it using server-side script, typically.

One pretty much universal way of upload on the client site is the (abstract) class System.Net.WebRequest. A concrete class is defined by the URI scheme through the factory method System.Net.WebRequest.Create(uri). Please see:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

The code sample on this page shows the use of HttpWebRequest class, which is used for HTTP and HTTPS protocols. On the same page, see other derived classes for FTP and file server protocols.

—SA
 
Share this answer
 
Comments
Prasad_Kulkarni 21-Jun-12 1:34am    
Good one 5!
Sergey Alexandrovich Kryukov 21-Jun-12 1:37am    
Thank you, Prasad.
--SA
C#
private void simpleButton1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedailog = new OpenFileDialog();
            string s;
            filedailog.ShowDialog();
            s = filedailog.FileName;
            textEdit1.Text = s;
            string Destination = "C:\\Users\\Administrator\\Desktop\\filesupload\\";
            var kl = s.Split('\\');
            string fname = kl[kl.Length - 1];
            string j = Destination;
            System.IO.File.Copy(s, Destination + fname, true);            
        }
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 21-Jun-12 1:33am    
Code formatted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900