目的:在浏览器页面启动上传下载CS软件,实现文件的批量下载与上传。

技术路线:

开发上传下载客户端CS程序与注册程序,压缩放到服务器端指定位置;

开发服务器端程序用以接收上传请求,压缩放到服务器端;

将数据服务端程序与客户端程序压缩包用IIS发布

开发前端页面,提供下载上传下载程序压缩包的功能,提供打开上传下载程序的功能;

内容:

1、上传下载CS客户端程序

采用C#开发语言开发,wpf界面,webclient等接口,http协议,实现数据的上传下载功能,实现文件记录写入后台数据库mysql中。   exe

2、注册程序(参考某博客资料)

采用C#开发语言,win32的相关注册表操作接口,实现上传下载程序写入注册表,以便前端页面调用 。   exe

3、文件上传后台程序

采用asp.net 技术,IIS,接收上传下载客户端程序的文件上传请求,实现服务器端文件的保存,以及照片缩略图的生成与保存。 axpx

4、前端页面功能入口

采用easyUI技术,javascript技术,实现上传下载程序的下载以及调用。html

=======================================================================

1、html页面启动功能

2、启动客户端程序

3、下载

4、上传

=====================================================================

1、上传下载CS客户端程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YpGlobalWPF;
using YpGlobalWPF.Dialog; namespace UpDownLoadApp
{
class StartUpApp
{
[STAThread]
public static void Main(string[] args)
{
//string[] s = { "yupontuploadapp://192.168.120.200_guangzhou_root_root_http://192.168.120.200/Data_http://192.168.120.200/uploadFileServer/Default.aspx" };
//args = s;
if (args.Length<)
{
return;
}
ParseExePara(args);
App app = new App();
app.InitializeComponent();
app.Run();
return;
} public static void ParseExePara(string[] args)
{
if (args.Length<)
{
return;
}
string paraRemoved = "yupontuploadapp://";
string para = args[];
para = para.Replace(paraRemoved, "").Trim();
if (!string.IsNullOrWhiteSpace(para)&&para.Length>)
{
string[] allParas=para.Split('_');
if (allParas.Length<)
{
return;
}
YpGlobalWPF.CommonUtil.Para = new CommonUtils.MySqlConnPara()
{
Host = allParas[],
DataBase = allParas[],
UserName = allParas[],
Password = allParas[]
};
if (allParas.Length>)
{
YpGlobalWPF.CommonUtil.CesiumDataBaseUrl = allParas[];
string upLoadFilePathRelative;
if (allParas[].Contains("127.0.0.1"))
{
upLoadFilePathRelative = YBCommonUtility.StringUtility.GetAfterRemovePreStr(allParas[], "127.0.0.1");
}
else if (allParas[].Contains("localhost"))
{
upLoadFilePathRelative = YBCommonUtility.StringUtility.GetAfterRemovePreStr(allParas[], "localhost");
}
else
{
upLoadFilePathRelative = YBCommonUtility.StringUtility.GetAfterRemovePreStr(allParas[], YpGlobalWPF.CommonUtil.Para.Host);
}
YpGlobalWPF.CommonUtil.UpLoadDataDirRelative = upLoadFilePathRelative;
YpGlobalWPF.CommonUtil.SourceFilePath = allParas[]+"/images/原始数据";
YpGlobalWPF.CommonUtil.FaultFilePath = allParas[] + "/images/缺陷数据";
}
if (allParas.Length>)
{
YpGlobalWPF.CommonUtil.ServerAspx = allParas[];
}
}
}
}
}
//using DbDAL;
//using DbModel;
using System;
using System.Collections.Generic;
//using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using YpGlobalWPF.Common;
using System.ComponentModel;
using System.Threading;
namespace YpGlobalWPF.Dialog
{
/// <summary>
/// frmLineProfile.xaml 的交互逻辑
/// </summary>
public partial class frmPictureTreeDownFile : Window,INotifyPropertyChanged
{
private IDictionary<string, string> _pictures;
private bool _bMaximized = false; private string _lineName=""; private string _poleName=""; private string _baseUrl = "";
public string PoleName
{
get { return _poleName; }
set
{
_poleName = value;
LinePoleName = _lineName + _poleName;
RaisePropertyChanged("PoleName");
}
} private string linePoleName; public string LinePoleName
{
get { return linePoleName; }
set
{
linePoleName = value;
RaisePropertyChanged("LinePoleName");
}
} private static frmPictureTreeDownFile picTree1; public static frmPictureTreeDownFile Instance
{
get
{
if (picTree1 == null)
{
picTree1 = new frmPictureTreeDownFile(null);
}
return picTree1;
}
set
{
picTree1 = value;
} } public frmPictureTreeDownFile(IDictionary<string, string> pics)
{
InitializeComponent();
_pictures = pics;
//
double scale = CommonUtil.ScaleValue;
//this.Width = 950 * scale;
//this.Height = 700 * scale;
} public bool Init(string baseUrl,string lineName,string poleName)
{
try
{
this._lineName = lineName;
this.PoleName = poleName;
this._baseUrl = baseUrl;
ViewModel.VM_PicTreeDownFile picTreeViewModel = new ViewModel.VM_PicTreeDownFile();
picTreeViewModel.LoadDataOnCommand(baseUrl, true, true);
if (picTreeViewModel.Children == null || picTreeViewModel.Children.Count == )
{
CommonUtil.ShowMessage("提示", "没找到照片!");
return false;
}
frmPictureTreeDownFile.Instance.picTree.DataContext = picTreeViewModel; List<NameValueItem> cmbLineSource = picTreeViewModel.GetCmbLines();
cmbLineSource.Insert(,new NameValueItem("全部","全部"));
frmPictureTreeDownFile.Instance.cmbLines.ItemsSource = cmbLineSource;
frmPictureTreeDownFile.Instance.cmbLines.SelectedValue = lineName;
frmPictureTreeDownFile.Instance.cmbLines_SelectionChanged(null, null); FillCmbPoles(lineName, poleName, picTreeViewModel); }
catch (Exception)
{
CommonUtil.ShowMessage("提示", "打开杆塔照片出错!");
return false;
} return true;
} private void FillCmbPoles(string lineName,string poleName,ViewModel.VM_PicTreeDownFile picTreeViewModel)
{
List<NameValueItem> cmbPoleSource = picTreeViewModel.GetLinePoles(lineName);
if (cmbPoleSource==null)
{
return;
}
cmbPoleSource.Insert(, new NameValueItem("全部", "全部"));
frmPictureTreeDownFile.Instance.cmbPoles.ItemsSource = cmbPoleSource;
if (poleName==null)
{
frmPictureTreeDownFile.Instance.cmbPoles.SelectedIndex = ;
return;
}
else
{
if (cmbPoleSource.Count>)
{
if (cmbPoleSource[].Value.ToString().EndsWith("#"))
{
poleName = poleName.Replace("号", "#");
if (!poleName.EndsWith("#"))
{
poleName += "#";
}
}
if (cmbPoleSource[].Value.ToString().EndsWith("号"))
{
poleName = poleName.Replace("#", "号");
if (!poleName.EndsWith("号"))
{
poleName += "号";
}
} }
frmPictureTreeDownFile.Instance.cmbPoles.SelectedValue = poleName;
}
frmPictureTreeDownFile.Instance.cmbPoles_SelectionChanged(null, null);
} private void OK_Click(object sender, RoutedEventArgs e)
{
this.Visibility = Visibility.Hidden;
} private bool _bMouseDown;
private System.Windows.Point _startPoint;
private void Gripe_MouseDown(object sender, MouseButtonEventArgs e)
{
_bMouseDown = true;
_startPoint = e.GetPosition(this);
sizeGripe.CaptureMouse();
this.Cursor = Cursors.SizeAll;
} private void Gripe_MouseMove(object sender, MouseEventArgs e)
{
if (_bMouseDown)
{
System.Windows.Point endPos = e.GetPosition(this);
this.Width = this.Width + (endPos.X - _startPoint.X);
this.Height = this.Height + (endPos.Y - _startPoint.Y);
_startPoint = endPos;
}
} private void Gripe_MouseUp(object sender, MouseButtonEventArgs e)
{
_bMouseDown = false;
sizeGripe.ReleaseMouseCapture();
this.Cursor = Cursors.Arrow;
} private TextBlock curSelectedItme = null; private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//ViewModel.VM_PicTree treeItem = (sender as TextBlock).Tag as ViewModel.VM_PicTree;
curSelectedItme = sender as TextBlock;//
} public event PropertyChangedEventHandler PropertyChanged; private void RaisePropertyChanged(string propName)
{
if (PropertyChanged!=null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
} private void Window_Loaded(object sender, RoutedEventArgs e)
{ } private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{ } private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Visibility = Visibility.Hidden;
} private void btnDownFile_Click(object sender, RoutedEventArgs e)
{
ViewModel.VM_PicTreeDownFile vmTree = (ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext;
if (!Directory.Exists(this.txtSavePath.Text.Trim()))
{
CommonUtil.ShowMessage("错误", "保存目录设置错误!");
txtSavePath.Text = "";
txtSavePath.Focus();
return;
}
this.waitP.Visibility = Visibility.Visible;
System.Windows.Forms.Application.DoEvents();
Thread newThread = new Thread(
new ParameterizedThreadStart(down));
Tuple<ViewModel.VM_PicTreeDownFile, string> tt = new Tuple<ViewModel.VM_PicTreeDownFile, string>(vmTree, this.txtSavePath.Text.Trim()); newThread.IsBackground = true;
newThread.Start(tt); //vmTree.DownFile(vmTree,this.txtSavePath.Text.Trim()); } private void down(Object para1)
{
Tuple<ViewModel.VM_PicTreeDownFile, string> para = para1 as Tuple<ViewModel.VM_PicTreeDownFile, string>;
para.Item1.DownFile(para.Item1, para.Item2);
System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
{
this.waitP.Visibility = Visibility.Collapsed;
CommonUtil.ShowMessage("提示", "数据下载完成!");
}));
} private void formCaption_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
_bMaximized = !_bMaximized;
if (_bMaximized)
{
this.WindowState = System.Windows.WindowState.Maximized;
}
else
{
this.WindowState = System.Windows.WindowState.Normal;
}
} private void formCaption_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
} private void cmbLines_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cmbLines.SelectedValue==null)
{
return;
}
string lineName = cmbLines.SelectedValue.ToString();
((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).SearchTree(lineName, this._baseUrl);
FillCmbPoles(lineName, null, (ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext);
} private void btnselpath_Click(object sender, RoutedEventArgs e)
{
string fullFilePath = string.Empty;
System.Windows.Forms.FolderBrowserDialog dilog = new System.Windows.Forms.FolderBrowserDialog();
dilog.Description = "请选择文件夹";
if (dilog.ShowDialog() == System.Windows.Forms.DialogResult.OK || dilog.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
{
fullFilePath = dilog.SelectedPath;
}
txtSavePath.Text = fullFilePath;
} private void cmbPoles_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (cmbPoles.SelectedValue == null)
{
return;
}
if (((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).Children[].Children.Count == )
{
return;
}
//int lineNameIndex = -1;
string poleName = cmbPoles.SelectedValue.ToString();
string lineName = cmbLines.SelectedValue.ToString();
//((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).GetLineNameIndex((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext, _lineName, ref lineNameIndex);//获取线路名称的索引
//if (lineNameIndex > 0)
//{
// ((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).SearchTreePoles(lineNameIndex + (_baseUrl.Equals(CommonUtil.PolePicturePath) ? 2 : 1), poleName,_baseUrl);
//}
if(((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).Children.Count==)
{
return;
}
((ViewModel.VM_PicTreeDownFile)frmPictureTreeDownFile.Instance.picTree.DataContext).SearchTreePoles2(lineName, poleName, _baseUrl);
} } }
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes; namespace UpDownLoadApp.View
{
/// <summary>
/// UploadFile.xaml 的交互逻辑
/// </summary>
public partial class frmUploadFile : Window
{
string _currentPath = "";//选择的要上传的文件夹路径
private bool _bMouseDown;
private System.Windows.Point _startPoint;
private bool _bMaximized = false;
private int _removeRecordIndex = ;
private ObservableCollection<Model.LogModel> _AllLog = new ObservableCollection<Model.LogModel>();
private ObservableCollection<Model.LogModel> _curAllLog = new ObservableCollection<Model.LogModel>(); public frmUploadFile()
{
InitializeComponent();
InitCmb();
this.lstLog.ItemsSource = _curAllLog;
} private static frmUploadFile picTree1; public static frmUploadFile Instance
{
get
{
if (picTree1 == null)
{
picTree1 = new frmUploadFile();
}
return picTree1;
}
set
{
picTree1 = value;
} } private void InitCmb()
{
this.cmbDataType.ItemsSource = Enum.GetNames(typeof(Model.enumDataType));
if (this.cmbDataType.Items!=null&&this.cmbDataType.Items.Count>)
{
this.cmbDataType.SelectedIndex = ;
}
if (cmbDataType.SelectedIndex == )
{
this.cmbDataLevel.ItemsSource = Enum.GetNames(typeof(Model.enumSourceFileLevelType));
}
else
{
this.cmbDataLevel.ItemsSource = Enum.GetNames(typeof(Model.enumFaultFileLevelType));
}
if (this.cmbDataLevel.Items != null && this.cmbDataLevel.Items.Count > )
{
this.cmbDataLevel.SelectedIndex = ;
}
this.cmbDataType.SelectionChanged += (s, e) =>
{
if (cmbDataType.SelectedIndex==)
{
this.cmbDataLevel.ItemsSource = Enum.GetNames(typeof(Model.enumSourceFileLevelType));
}
else
{
this.cmbDataLevel.ItemsSource = Enum.GetNames(typeof(Model.enumFaultFileLevelType));
}
if (this.cmbDataLevel.Items!=null&&this.cmbDataLevel.Items.Count>)
{
this.cmbDataLevel.SelectedIndex = ;
}
};
} private void Window_Loaded(object sender, RoutedEventArgs e)
{ } private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{ } private void formCaption_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
_bMaximized = !_bMaximized;
if (_bMaximized)
{
this.WindowState = System.Windows.WindowState.Maximized;
}
else
{
this.WindowState = System.Windows.WindowState.Normal;
}
} private void formCaption_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
} private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ } private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{
this.Visibility = Visibility.Hidden;
} private void Gripe_MouseDown(object sender, MouseButtonEventArgs e)
{
_bMouseDown = true;
_startPoint = e.GetPosition(this);
sizeGripe.CaptureMouse();
this.Cursor = Cursors.SizeAll;
} private void Gripe_MouseMove(object sender, MouseEventArgs e)
{
if (_bMouseDown)
{
System.Windows.Point endPos = e.GetPosition(this);
this.Width = this.Width + (endPos.X - _startPoint.X);
this.Height = this.Height + (endPos.Y - _startPoint.Y);
_startPoint = endPos;
}
} private void Gripe_MouseUp(object sender, MouseButtonEventArgs e)
{
_bMouseDown = false;
sizeGripe.ReleaseMouseCapture();
this.Cursor = Cursors.Arrow;
} /// <summary>
/// 上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDownFile_Click(object sender, RoutedEventArgs e)
{
_removeRecordIndex = ;
chkAllLog.IsChecked = true;
_curAllLog.Clear();
_AllLog.Clear();
string serverAspx = YpGlobalWPF.CommonUtil.ServerAspx;//服务器端网页
ViewModel.UpLoadFile upLoadFile = new ViewModel.UpLoadFile(ViewModel.UpLoadFile.GetDataBaseType(_currentPath));
upLoadFile.proBarEvent += updataH_ProcessChanged;
upLoadFile.LogMessageEvent += upLoadFile_LogMessageEvent;
upLoadFile.UpLoadDir(_currentPath,serverAspx);
} void upLoadFile_LogMessageEvent(string log)
{
_AllLog.Add(new Model.LogModel { Message = log });
if (_AllLog.Count>)
{
if(_AllLog[_removeRecordIndex].Message.Contains("失败"))
{
_AllLog.RemoveAt(_removeRecordIndex);
}
else
{
if (_removeRecordIndex<_AllLog.Count-)
{
_removeRecordIndex++;
}
}
}
if (_AllLog.Count>)
{
_AllLog.RemoveAt();
}
_curAllLog.Clear();
foreach (var item in _AllLog)
{
_curAllLog.Add(item);
}
System.Windows.Forms.Application.DoEvents();
} void updataH_ProcessChanged(int TotalCount, int curCount)
{
this.proBar.Value = (int)Math.Round((double)(curCount * ) / TotalCount, );
System.Windows.Forms.Application.DoEvents();
if (curCount >= TotalCount)
{
MessageBox.Show("上传完成!");
}
} private void btnselpath_Click(object sender, RoutedEventArgs e)
{
try
{
string fullFilePath = string.Empty;
System.Windows.Forms.FolderBrowserDialog dilog = new System.Windows.Forms.FolderBrowserDialog();
dilog.Description = "请选择文件夹";
dilog.SelectedPath = _currentPath;
System.Windows.Forms.DialogResult dlgResult = dilog.ShowDialog();
if (dlgResult == System.Windows.Forms.DialogResult.OK || dlgResult == System.Windows.Forms.DialogResult.Yes)
{
fullFilePath = dilog.SelectedPath;
this.txtInputPath.Text = fullFilePath;
_currentPath = dilog.SelectedPath;
ReSetCmb(fullFilePath);
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(ex.ToString());
}
} private void ReSetCmb(string filefPath)
{
string type = ViewModel.UpLoadFile.GetDataBaseType(filefPath);
string levelType = ViewModel.UpLoadFile.GetFileLevelType(filefPath);
if (type.Equals(Model.enumDataType.原始数据.ToString()))
{
this.cmbDataType.SelectedIndex = ;
}
else if (type.Equals(Model.enumDataType.缺陷数据.ToString()))
{
this.cmbDataType.SelectedIndex = ;
}
this.cmbDataLevel.SelectedItem = levelType;
} private void OK_Click(object sender, RoutedEventArgs e)
{
this.Visibility = Visibility.Hidden;
} private void chkAllLog_Checked(object sender, RoutedEventArgs e)
{
_curAllLog.Clear();
foreach (var item in _AllLog)
{
_curAllLog.Add(item);
}
} private void chkSucceLog_Checked(object sender, RoutedEventArgs e)
{
IEnumerable<Model.LogModel> a = _AllLog.Where(t => t.Message.Contains("成功"));
_curAllLog.Clear();
foreach (var item in a)
{
_curAllLog.Add(item);
}
} private void chkFailLog_Checked(object sender, RoutedEventArgs e)
{
IEnumerable<Model.LogModel> a = _AllLog.Where(t => t.Message.Contains("失败"));
_curAllLog.Clear();
foreach (var item in a)
{
_curAllLog.Add(item);
}
} }
}

2、注册程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace RegisterUpLoadApp
{
class Program
{
public const string KEYNAME = "yupontuploadapp";
public const string EXENAME = "UpDownLoadApp.exe";
static void Main(string[] args)
{
string regeditExePath=System.AppDomain.CurrentDomain.BaseDirectory;
regeditExePath = System.IO.Path.Combine(regeditExePath, @"UpLoadClient\");
RegeditManager.InstallerDemo_AfterUninstall(KEYNAME, regeditExePath);
RegeditManager.InstallerDemo_AfterInstall(regeditExePath, EXENAME, KEYNAME);
Console.ReadKey();
}
}
}
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text; namespace RegisterUpLoadApp
{
public class RegeditManager
{ /// <summary>
////// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void InstallerDemo_AfterInstall(string targetdirPath, string exeName,string regeditKeyName)
{
Msg("文件路径:" + Path.Combine(targetdirPath, exeName), targetdirPath);
var result = RegeditAdd(regeditKeyName, Path.Combine(targetdirPath, exeName), "");
Msg("注册表修改是否成功:" + result, targetdirPath);
}
/// <summary>
/// 卸载完成之后触发
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void InstallerDemo_AfterUninstall(string keyName,string targetPaht)
{
//throw new NotImplementedException();
Msg("注册表信息删除开始:", targetPaht);
var result = RegeditDelete(keyName, targetPaht);
Msg("注册表信息删除:" + result, targetPaht);
}
/// <summary>
/// 注册协议
/// </summary>
/// <param name="Root_Key">根节点</param>
/// <param name="file_application_path">应用程序路径</param>
/// <param name="file_application_ico">应用程序打开图标,可选值</param>
/// <returns></returns>
public static bool RegeditAdd(string Root_Key, string file_application_path, string file_application_ico)
{
RegistryKey reg_ClassRoot = Registry.ClassesRoot;
string targetdirPath="";
try
{
targetdirPath = System.IO.Path.GetDirectoryName(file_application_path);
RegistryKey reg_key = reg_ClassRoot.OpenSubKey(Root_Key, true);
if (reg_key == null)
{
//创建子节点HKEY_CLASSES_ROOT\tpswftest
RegistryKey reg_sjbs = reg_ClassRoot.CreateSubKey(Root_Key);
//添加默认项
reg_sjbs.SetValue("", "URL: " + Root_Key + " Protocol Handler");
//协议别名
reg_sjbs.SetValue("URL Protocol", file_application_path);
//创建[HKEY_CLASSES_ROOT\tpswftest\DefaultIcon]
RegistryKey reg_DefaultIcon = reg_sjbs.CreateSubKey("DefaultIcon");
if (!String.IsNullOrEmpty(file_application_ico))
{
//设置自定义图标
reg_DefaultIcon.SetValue("", file_application_ico);
}
else
{
//设置系统定义图标
reg_DefaultIcon.SetValue("", file_application_path + ",1");
}
//创建呼出处理程序[HKEY_CLASSES_ROOT\tpswftest\shell\open\command]
RegistryKey reg_command = reg_sjbs.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command");
//%1 表示传递的参数,再次%1表示调用处显示链接文本
reg_command.SetValue("", "\"" + file_application_path + "\" \"%1\"");
}
return true;
}
catch (Exception ex)
{
Msg(ex.Message.ToString(), targetdirPath);
return false;
}
finally { reg_ClassRoot.Close(); }
} /// <summary>
/// 删除协议
/// </summary>
/// <param name="Root_Key">根节点</param>
/// <returns></returns>
public static bool RegeditDelete(string Root_Key,string targetPaht)
{
//获取注册表HKEY_CLASSES_ROOT
RegistryKey reg_ClassRoot = Registry.ClassesRoot;
try
{
//获取注册表[HKEY_CLASSES_ROOT\tpswftest]项
RegistryKey reg_sjbs = reg_ClassRoot.OpenSubKey(Root_Key, true);
if (reg_sjbs != null)
{
reg_ClassRoot.DeleteSubKeyTree(Root_Key);
return true;
}
else
{
//Msg("注册表中" + reg_ClassRoot + "\\" + Root_Key + "不存在!", "");
return false;
} }
catch (Exception ex)
{
//添加错误日志
Msg(ex.Message.ToString(), "");
return false;
}
finally { reg_ClassRoot.Close(); }
}
/// <summary>
/// 日志
/// </summary>
/// <param name="message"></param>
public static void Msg(string message,string targetdirPath)
{
string rootPath = targetdirPath;
if (string.IsNullOrEmpty(rootPath))
{
rootPath = "D:\\runsoft\\meswfTest";
}
try
{ Console.WriteLine(message);
}
catch (Exception _exception)
{
throw;
}
}
}
}

3、文件上传后台程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace UpDownLoadFileServer
{
/// <summary>
/// 文件上传服务端zhanghaifeng20181025
/// </summary>
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string f in Request.Files.AllKeys)
{
try
{
HttpPostedFile file = Request.Files[f];
string relativePath = Request.QueryString["relativePath"];
string webSiteName = Request.QueryString["webSiteName"];
//webSiteName = "jixunzhongxinCesium/cloud/";
string serverLocalFilePath = Server.MapPath("../" + webSiteName + "/" + relativePath);
string filePathName = Path.GetDirectoryName(serverLocalFilePath);
Directory.CreateDirectory(filePathName);
file.SaveAs(serverLocalFilePath);
SaveThumb(serverLocalFilePath);
}
catch (Exception)
{ }
}
} public static void SaveThumb(string serverLocalFilePath)
{
try
{
string newPath = serverLocalFilePath.Replace("缺陷数据", "缺陷数据缩略图").Replace("原始数据", "原始数据缩略图");
string filePathName = Path.GetDirectoryName(newPath);
Directory.CreateDirectory(filePathName);
WebImgUtil.ImageUtil.MakeThumbnail(serverLocalFilePath, newPath, , , "HW");
}
catch (Exception)
{
} }
}
}

4、前端页面功能入口

<div id="uploadpanel" class="easyui-window" title="数据传输" data-options="closable:true,collapsible:false,minimizable:false,closed:true" style="width:300px;height:180px; padding-top: 30px">
<div style="text-align: center">
<button id="btnloaduploadexe">程序注册</button>
<p></p>
<a id="aupload" style="font-size: 14px" href="yupontuploadapp://host_db_user_pass_images_aspx">
启动程序
</a>
<p></p>
<p></p>
<p>说明:第一次使用上传下载程序需要先注册</p>
</div>
</div>

文件上传下载(C#,web,asp.net)的更多相关文章

  1. WEB文件上传下载功能

    WEB文件上传下载在日常工作中经常用到的功能 这里用到JS库 http://files.cnblogs.com/meilibao/ajaxupload.3.5.js 上传代码段(HTML) <% ...

  2. JAVA Web 之 struts2文件上传下载演示(二)(转)

    JAVA Web 之 struts2文件上传下载演示(二) 一.文件上传演示 详细查看本人的另一篇博客 http://titanseason.iteye.com/blog/1489397 二.文件下载 ...

  3. JAVA Web 之 struts2文件上传下载演示(一)(转)

    JAVA Web 之 struts2文件上传下载演示(一) 一.文件上传演示 1.需要的jar包 大多数的jar包都是struts里面的,大家把jar包直接复制到WebContent/WEB-INF/ ...

  4. java web 文件上传下载

    文件上传下载案例: 首先是此案例工程的目录结构:

  5. SpringMVC整合fastdfs-client-java实现web文件上传下载

    原文:http://blog.csdn.net/wlwlwlwl015/article/details/52682153 本篇blog主要记录一下SpringMVC整合FastDFS的Java客户端实 ...

  6. iOS开发之结合asp.net webservice实现文件上传下载

    iOS开发中会经常用到文件上传下载的功能,这篇文件将介绍一下使用asp.net webservice实现文件上传下载. 首先,让我们看下文件下载. 这里我们下载cnblogs上的一个zip文件.使用N ...

  7. SpringMVC文件上传下载

    在Spring MVC的基础框架搭建起来后,我们测试了spring mvc中的返回值类型,如果你还没有搭建好springmvc的架构请参考博文->http://www.cnblogs.com/q ...

  8. JavaWeb实现文件上传下载功能实例解析

    转:http://www.cnblogs.com/xdp-gacl/p/4200090.html JavaWeb实现文件上传下载功能实例解析 在Web应用系统开发中,文件上传和下载功能是非常常用的功能 ...

  9. WebService实现文件上传下载

    一:服务端:一个普通java web工程 package com.wzh.file; import com.sun.xml.ws.developer.StreamingAttachment; impo ...

随机推荐

  1. DFT的理解

    在以前学习的离散傅立叶变换(DFT),总是不能理解只是知道公式 X(k) = Σx(n) * WNnk    ,也不知道如何得来的. 现在可以聊聊了,因为最近在使用MATLAB实际的操作了所以比以前了 ...

  2. 匿名类型与Select方法实现自定义对象插入局部表结构中

    在提取局部表结构数据时,通过Select选取需要的字段,如下句,此时其实产生了一个不用于_menuMan的原新数据类型new { c.SYS_COMMANDS_ID,c.TXT_COMMANDTITL ...

  3. 生成signature

    签名规则说明 1. 将参数先按键值排序(只做一级排序),进行key和value的拼接 2. 拼接完后,在最后面再拼接上分配的 appSecret 然后用sha1对拼接串加密 签名示例 假如传入参数: ...

  4. DIKW模型与数据工程

    DIKW 体系 DIKW体系是关于数据.信息.知识及智慧的体系,可以追溯至托马斯·斯特尔那斯·艾略特所写的诗--<岩石>.在首段,他写道:“我们在哪里丢失了知识中的智慧?又在哪里丢失了信息 ...

  5. git commit 提交的时候,出现*** Please tell me who you are. git config --global 。。。问题

    $ git commit -a -m 'v6' *** Please tell me who you are. Run git config --global user.email "you ...

  6. MySQL 示例数据库sakila-db的安装

    最近在看 “高性能MySql”这本神书,发现上面很多例子采用的官方示例数据库sakila. 官方示例数据库 下载地址 http://dev.mysql.com/doc/index-other.html ...

  7. Python名称空间和闭包

    一.名称空间 1.定义:又名 name space,顾名思义,就是存放名字的地方.比如:若变量x = 1,1存放在内存中, 而名称空间正是存放名字x与1绑定关系的地方. 2.分类: locals : ...

  8. 476. Number Complement 二进制中的相反对应数

    [抄题]: Given a positive integer, output its complement number. The complement strategy is to flip the ...

  9. 使用RVM更新Ruby 版本

    http://rvm.io/rvm/install Install RVM (development version): \curl -sSL https://get.rvm.io | bash Wi ...

  10. 面试题--CVTE

    2.HashMap和HashSet的实现原理,hashset 和hashMap区别 HashSet底层就是HashMap实现的, *HashMap* *HashSet* HashMap实现了Map接口 ...