文件下载
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
string path = folderBrowserDialog1.SelectedPath;
WebClient webc = new WebClient();
string str = System.Environment.CurrentDirectory;
string v_OpenFilePath = str + "\\XX市电子政务信息化建设情况调查表.docx";//服务器端路径
string receivePath = path + "\\XX市电子政务信息化建设情况调查表.docx";
webc.DownloadFile(v_OpenFilePath, receivePath + System.IO.Path.GetFileName(v_OpenFilePath));
MessageBox.Show("下载完成");
}
需要添加 引用
using System.Net;
(folderBrowserDialog1.ShowDialog() == DialogResult.OK)
这句话是FolderBrowserDialog 控件的使用
System.Environment.CurrentDirectory
这句是拿到Debug 下的路径
弹出一个文档
string str = System.Environment.CurrentDirectory;
string v_OpenFilePath = str + "/API.CHM";
//先判断文件是否存在,不存在则提示
if (!System.IO.File.Exists(v_OpenFilePath))
{
MessageBox.Show("安装根目录下帮助文件不存在!", "操作提示");//
return;
}
//存在则打开
System.Diagnostics.Process.Start(v_OpenFilePath);
弹出对话框(含确定 取消按钮)
MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
DialogResult dr = MessageBox.Show("确定要退出吗?", "退出系统", messButton);
if (dr == DialogResult.OK)//如果点击“确定”按钮
{
this.Close();
}
else//如果点击“取消”按钮
{ }
public void newTabP(Form frm, string name, string tabName)
{
if (ifin(tabList, tabName))
{
tabList.Add(tabName);
string clickInfo = string.Empty;
clickInfo = name;
//创建一个TabPage
TabPage tabPage = new TabPage();
//设置选项卡文本
tabPage.Text = name;
//选项卡名字(可以通过这个名字来访问到tabControl1中的选项卡)
tabPage.Name = tabName;
frm.Name = tabName;
frm.TopLevel = false;
//给Form去边框
frm.FormBorderStyle = FormBorderStyle.None;
//把page添加到tabPage中
tabPage.Controls.Add(frm);
//在tabPage选项卡中显示出来
frm.Show();
//添加选项卡tabPage到TabControl中
tabControl1.TabPages.Add(tabPage);
}
tabControl1.SelectedIndex = tabList.IndexOf(tabName) + 1;
}