| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 759 人关注过本帖
标题:[经验]很惊讶的事情!-->唐伯猫转移
只看楼主 加入收藏
天气预报不准
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-3-16
收藏
 问题点数:0 回复次数:5 
[经验]很惊讶的事情!-->唐伯猫转移

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;

namespace WindowsApplication18
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tpUpload;
private System.Windows.Forms.TabPage tpDownload;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox tbDownloadURL;
private System.Windows.Forms.TextBox tbSaveAs;
private System.Windows.Forms.Button btnDownloadBrowser;
private System.Windows.Forms.Button btn;
private System.Windows.Forms.Button btnDownloadExit;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.SaveFileDialog saveFileDialog;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tpUpload = new System.Windows.Forms.TabPage();
this.btnDownloadExit = new System.Windows.Forms.Button();
this.btn = new System.Windows.Forms.Button();
this.btnDownloadBrowser = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.tbSaveAs = new System.Windows.Forms.TextBox();
this.tbDownloadURL = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.tpDownload = new System.Windows.Forms.TabPage();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.tabControl1.SuspendLayout();
this.tpUpload.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tpUpload);
this.tabControl1.Controls.Add(this.tpDownload);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(292, 273);
this.tabControl1.TabIndex = 0;
//
// tpUpload
//
this.tpUpload.Controls.Add(this.btnDownloadExit);
this.tpUpload.Controls.Add(this.btn);
this.tpUpload.Controls.Add(this.btnDownloadBrowser);
this.tpUpload.Controls.Add(this.label3);
this.tpUpload.Controls.Add(this.tbSaveAs);
this.tpUpload.Controls.Add(this.tbDownloadURL);
this.tpUpload.Controls.Add(this.label2);
this.tpUpload.Controls.Add(this.label1);
this.tpUpload.Location = new System.Drawing.Point(4, 21);
this.tpUpload.Name = "tpUpload";
this.tpUpload.Size = new System.Drawing.Size(284, 248);
this.tpUpload.TabIndex = 0;
this.tpUpload.Text = "下载";
//
// btnDownloadExit
//
this.btnDownloadExit.Location = new System.Drawing.Point(208, 176);
this.btnDownloadExit.Name = "btnDownloadExit";
this.btnDownloadExit.Size = new System.Drawing.Size(64, 24);
this.btnDownloadExit.TabIndex = 7;
this.btnDownloadExit.Text = "退出";
this.btnDownloadExit.Click += new System.EventHandler(this.btnDownloadExit_Click);
//
// btn
//
this.btn.Location = new System.Drawing.Point(128, 176);
this.btn.Name = "btn";
this.btn.Size = new System.Drawing.Size(56, 24);
this.btn.TabIndex = 6;
this.btn.Text = "下载";
this.btn.Click += new System.EventHandler(this.btn_Click);
//
// btnDownloadBrowser
//
this.btnDownloadBrowser.Location = new System.Drawing.Point(208, 120);
this.btnDownloadBrowser.Name = "btnDownloadBrowser";
this.btnDownloadBrowser.Size = new System.Drawing.Size(64, 24);
this.btnDownloadBrowser.TabIndex = 5;
this.btnDownloadBrowser.Text = "浏览";
this.btnDownloadBrowser.Click += new System.EventHandler(this.btnDownloadBrowser_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 184);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(112, 16);
this.label3.TabIndex = 4;
this.label3.Text = "从指定网址下载文件到本机";
//
// tbSaveAs
//
this.tbSaveAs.Location = new System.Drawing.Point(56, 120);
this.tbSaveAs.Name = "tbSaveAs";
this.tbSaveAs.Size = new System.Drawing.Size(144, 21);
this.tbSaveAs.TabIndex = 3;
this.tbSaveAs.Text = "";
//
// tbDownloadURL
//
this.tbDownloadURL.Location = new System.Drawing.Point(56, 64);
this.tbDownloadURL.Name = "tbDownloadURL";
this.tbDownloadURL.Size = new System.Drawing.Size(144, 21);
this.tbDownloadURL.TabIndex = 2;
this.tbDownloadURL.Text = "http://";
//
// label2
//
this.label2.Location = new System.Drawing.Point(0, 120);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 1;
this.label2.Text = "保存为";
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 24);
this.label1.TabIndex = 0;
this.label1.Text = "网址";
//
// tpDownload
//
this.tpDownload.Location = new System.Drawing.Point(4, 21);
this.tpDownload.Name = "tpDownload";
this.tpDownload.Size = new System.Drawing.Size(284, 248);
this.tpDownload.TabIndex = 1;
this.tpDownload.Text = "上载";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.tabControl1);
this.Name = "Form1";
this.Text = "文件上载/下载器";
this.tabControl1.ResumeLayout(false);
this.tpUpload.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void btnDownloadBrowser_Click(object sender, System.EventArgs e)
{
if (saveFileDialog.ShowDialog()==DialogResult.OK)
{
tbSaveAs.Text=saveFileDialog.FileName;
}
else
{
MessageBox.Show("没有填入保存的文件名","Warning");
}
}

private void btnDownloadExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}

private void btn_Click(object sender, System.EventArgs e)
{
string URL=tbDownloadURL.Text;
this.Text="正在下载.....";
client.DownloadFile(URL,tbSaveAs.Text);
this.Text="文件上载/下载器";
}


}
}
D:\xiaoxiao\WindowsApplication18\Form1.cs(231): 找不到类型或命名空间名称“client”(是否缺少 using 指令或程序集引用?)

搜索更多相关主题的帖子: System using Forms Windows 经验 
2006-04-25 11:44
天气预报不准
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-3-16
收藏
得分:0 
怎么在开始引入client呢?我用using System .net.WebClinet好象不行,提示说这是类不是命名空间

哎!发型有点乱。。。。。。
2006-04-25 11:46
小笨笨
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:1169
专家分:0
注 册:2006-4-17
收藏
得分:0 

private void btn_Click(object sender, System.EventArgs e)
{
string URL=tbDownloadURL.Text;
this.Text="正在下载.....";
client.DownloadFile(URL,tbSaveAs.Text);
this.Text="文件上载/下载器";
}

这个client是什么?是网页上的控件吗?


欢迎光临我的博客: http://smallfools.blog./default.html
2006-04-25 12:10
天气预报不准
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-3-16
收藏
得分:0 
不是啊,Windows应用程序里面的!

哎!发型有点乱。。。。。。
2006-04-25 13:13
天气预报不准
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-3-16
收藏
得分:0 
呵呵,问题得到解决了,我忘了定义private WebClient client=new WebClient();
前面还要加using System.Net.Webclient;

哎!发型有点乱。。。。。。
2006-04-25 17:33
乱弹琴
Rank: 1
等 级:新手上路
威 望:1
帖 子:1665
专家分:0
注 册:2006-3-7
收藏
得分:0 
看的一脸茫然啊

男人的謊言可以騙女人的壹夜! 女人的謊言可以騙男人的壹生!
2006-04-26 12:56
快速回复:[经验]很惊讶的事情!-->唐伯猫转移
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018144 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved