Click here to Skip to main content
15,891,905 members
Articles / Desktop Programming / Win32

Transfer files using Web Services

Rate me:
Please Sign up or sign in to vote.
2.55/5 (18 votes)
11 Sep 2008Ms-PL 148K   4.2K   46  
We can use Microsoft SOAP protocol to transfer files between a client and a server. It's easy to do it even through a firewall, and also it's cross platform.
namespace WindowsApplication1
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.BtnDownloadFile = new System.Windows.Forms.Button();
            this.BtnOpen = new System.Windows.Forms.Button();
            this.BtnUploadFile = new System.Windows.Forms.Button();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.txtUpPath = new System.Windows.Forms.TextBox();
            this.Namess = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.txtUpName = new System.Windows.Forms.TextBox();
            this.Up = new System.Windows.Forms.GroupBox();
            this.label8 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.download = new System.Windows.Forms.GroupBox();
            this.txtLocalName = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.txtDownName = new System.Windows.Forms.TextBox();
            this.txtLocalPath = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.linkLabel2 = new System.Windows.Forms.LinkLabel();
            this.Up.SuspendLayout();
            this.download.SuspendLayout();
            this.SuspendLayout();
            // 
            // BtnDownloadFile
            // 
            this.BtnDownloadFile.Location = new System.Drawing.Point(209, 129);
            this.BtnDownloadFile.Name = "BtnDownloadFile";
            this.BtnDownloadFile.Size = new System.Drawing.Size(92, 23);
            this.BtnDownloadFile.TabIndex = 1;
            this.BtnDownloadFile.Text = "DownloadFile";
            this.BtnDownloadFile.UseVisualStyleBackColor = true;
            this.BtnDownloadFile.Click += new System.EventHandler(this.BtnDownloadFile_Click);
            // 
            // BtnOpen
            // 
            this.BtnOpen.Location = new System.Drawing.Point(100, 106);
            this.BtnOpen.Name = "BtnOpen";
            this.BtnOpen.Size = new System.Drawing.Size(75, 23);
            this.BtnOpen.TabIndex = 2;
            this.BtnOpen.Text = "Open";
            this.BtnOpen.UseVisualStyleBackColor = true;
            this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
            // 
            // BtnUploadFile
            // 
            this.BtnUploadFile.Location = new System.Drawing.Point(209, 106);
            this.BtnUploadFile.Name = "BtnUploadFile";
            this.BtnUploadFile.Size = new System.Drawing.Size(98, 23);
            this.BtnUploadFile.TabIndex = 3;
            this.BtnUploadFile.Text = "UploadFile";
            this.BtnUploadFile.UseVisualStyleBackColor = true;
            this.BtnUploadFile.Click += new System.EventHandler(this.BtnUploadFile_Click);
            // 
            // openFileDialog1
            // 
            this.openFileDialog1.FileName = "openFileDialog1";
            // 
            // txtUpPath
            // 
            this.txtUpPath.Location = new System.Drawing.Point(66, 34);
            this.txtUpPath.Name = "txtUpPath";
            this.txtUpPath.Size = new System.Drawing.Size(215, 21);
            this.txtUpPath.TabIndex = 4;
            this.txtUpPath.Text = "E:\\";
            // 
            // Namess
            // 
            this.Namess.AutoSize = true;
            this.Namess.Location = new System.Drawing.Point(25, 37);
            this.Namess.Name = "Namess";
            this.Namess.Size = new System.Drawing.Size(35, 12);
            this.Namess.TabIndex = 5;
            this.Namess.Text = "Path:";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(24, 62);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(35, 12);
            this.label1.TabIndex = 6;
            this.label1.Text = "Name:";
            // 
            // txtUpName
            // 
            this.txtUpName.Location = new System.Drawing.Point(66, 61);
            this.txtUpName.Name = "txtUpName";
            this.txtUpName.Size = new System.Drawing.Size(215, 21);
            this.txtUpName.TabIndex = 7;
            // 
            // Up
            // 
            this.Up.Controls.Add(this.label8);
            this.Up.Controls.Add(this.label9);
            this.Up.Controls.Add(this.txtUpName);
            this.Up.Controls.Add(this.BtnUploadFile);
            this.Up.Controls.Add(this.txtUpPath);
            this.Up.Controls.Add(this.BtnOpen);
            this.Up.Controls.Add(this.label1);
            this.Up.Controls.Add(this.Namess);
            this.Up.Location = new System.Drawing.Point(12, 12);
            this.Up.Name = "Up";
            this.Up.Size = new System.Drawing.Size(420, 144);
            this.Up.TabIndex = 8;
            this.Up.TabStop = false;
            this.Up.Text = "Upload";
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(297, 66);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(107, 12);
            this.label8.TabIndex = 16;
            this.label8.Text = "Local file\'s name";
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(297, 37);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(107, 12);
            this.label9.TabIndex = 15;
            this.label9.Text = "Local file\'s path";
            // 
            // download
            // 
            this.download.Controls.Add(this.txtLocalName);
            this.download.Controls.Add(this.label7);
            this.download.Controls.Add(this.label6);
            this.download.Controls.Add(this.label5);
            this.download.Controls.Add(this.label4);
            this.download.Controls.Add(this.txtDownName);
            this.download.Controls.Add(this.txtLocalPath);
            this.download.Controls.Add(this.label2);
            this.download.Controls.Add(this.label3);
            this.download.Controls.Add(this.BtnDownloadFile);
            this.download.Location = new System.Drawing.Point(12, 162);
            this.download.Name = "download";
            this.download.Size = new System.Drawing.Size(420, 161);
            this.download.TabIndex = 9;
            this.download.TabStop = false;
            this.download.Text = "Download";
            // 
            // txtLocalName
            // 
            this.txtLocalName.Location = new System.Drawing.Point(66, 91);
            this.txtLocalName.Name = "txtLocalName";
            this.txtLocalName.Size = new System.Drawing.Size(176, 21);
            this.txtLocalName.TabIndex = 16;
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(23, 95);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(35, 12);
            this.label7.TabIndex = 15;
            this.label7.Text = "Name:";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(269, 95);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(107, 12);
            this.label6.TabIndex = 14;
            this.label6.Text = "Local file\'s name";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.BackColor = System.Drawing.Color.Red;
            this.label5.Location = new System.Drawing.Point(260, 23);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(131, 12);
            this.label5.TabIndex = 13;
            this.label5.Text = "File\'s name on server";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(270, 63);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(107, 12);
            this.label4.TabIndex = 12;
            this.label4.Text = "Local file\'s path";
            // 
            // txtDownName
            // 
            this.txtDownName.Location = new System.Drawing.Point(66, 20);
            this.txtDownName.Name = "txtDownName";
            this.txtDownName.Size = new System.Drawing.Size(176, 21);
            this.txtDownName.TabIndex = 11;
            // 
            // txtLocalPath
            // 
            this.txtLocalPath.Location = new System.Drawing.Point(66, 58);
            this.txtLocalPath.Name = "txtLocalPath";
            this.txtLocalPath.Size = new System.Drawing.Size(176, 21);
            this.txtLocalPath.TabIndex = 8;
            this.txtLocalPath.Text = "c:\\";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(24, 21);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(35, 12);
            this.label2.TabIndex = 10;
            this.label2.Text = "Name:";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(25, 62);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(35, 12);
            this.label3.TabIndex = 9;
            this.label3.Text = "Path:";
            // 
            // linkLabel1
            // 
            this.linkLabel1.AutoSize = true;
            this.linkLabel1.Location = new System.Drawing.Point(63, 340);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(89, 12);
            this.linkLabel1.TabIndex = 10;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "Any questions?";
            this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
            // 
            // linkLabel2
            // 
            this.linkLabel2.AutoSize = true;
            this.linkLabel2.Location = new System.Drawing.Point(281, 340);
            this.linkLabel2.Name = "linkLabel2";
            this.linkLabel2.Size = new System.Drawing.Size(131, 12);
            this.linkLabel2.TabIndex = 11;
            this.linkLabel2.TabStop = true;
            this.linkLabel2.Text = "About www.treable.com";
            this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(442, 370);
            this.Controls.Add(this.linkLabel2);
            this.Controls.Add(this.linkLabel1);
            this.Controls.Add(this.download);
            this.Controls.Add(this.Up);
            this.Name = "Form1";
            this.Text = "TranferFile www.treable.com";
            this.Up.ResumeLayout(false);
            this.Up.PerformLayout();
            this.download.ResumeLayout(false);
            this.download.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button BtnDownloadFile;
        private System.Windows.Forms.Button BtnOpen;
        private System.Windows.Forms.Button BtnUploadFile;
        private System.Windows.Forms.OpenFileDialog openFileDialog1;
        private System.Windows.Forms.TextBox txtUpPath;
        private System.Windows.Forms.Label Namess;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox txtUpName;
        private System.Windows.Forms.GroupBox Up;
        private System.Windows.Forms.GroupBox download;
        private System.Windows.Forms.TextBox txtDownName;
        private System.Windows.Forms.TextBox txtLocalPath;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox txtLocalName;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.LinkLabel linkLabel1;
        private System.Windows.Forms.LinkLabel linkLabel2;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior) www.treaple.com
China China
Treaple offshore outsourcing software services providing mobile(Pocket pc,smartphone and wince.net) software,mobile GIS(Mobile map),Desktop GIS(Desktop map), GPS,GSM Locating Services,Voip,Multimedia(Audio,Video) and web design offshore outsourcing software development services.We have developed lots of projects on Microsoft Poccket pc 5.0/6.0,smartphone 5.0/6.0 and Microsoft windows and got strong background in Microsoft MapPoint, ESRI ArcGIS, Map info,Google map etc
Our website below: http://www.szwyqz.com

Comments and Discussions