SVN r535
SVN-Revision: r535
This commit is contained in:
@@ -33,6 +33,10 @@ namespace Lskj.Control
|
||||
/// 存储文件地址(用于保存上传)
|
||||
/// </summary>
|
||||
public string filepath;
|
||||
/// <summary>
|
||||
/// 存储原文件名
|
||||
/// </summary>
|
||||
public string lasttext;
|
||||
public LabelRemarkEdit()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -51,8 +55,45 @@ namespace Lskj.Control
|
||||
private void OnDragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var file = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
|
||||
txtEdit.Text = Path.GetFileName(file);
|
||||
this.filepath = file;
|
||||
string filename = Path.GetFileName(file);
|
||||
if (!string.IsNullOrEmpty(lasttext))
|
||||
{
|
||||
if (string.Equals(lasttext, filename, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
MessageUtil.Show("检测到更改文件和原文件完全一样!");
|
||||
}
|
||||
else
|
||||
{
|
||||
string prefix1 = GetPrefixBeforeLastS(filename, StringComparison.OrdinalIgnoreCase);
|
||||
string prefix2 = GetPrefixBeforeLastS(lasttext, StringComparison.OrdinalIgnoreCase);
|
||||
if (string.Equals(prefix1, prefix2, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
txtEdit.Text = filename;
|
||||
this.filepath = file;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("检测到更改文件和原文件不匹配!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 取出最后一次出现 "-S" 之前的部分(不含扩展名)
|
||||
/// </summary>
|
||||
private static string GetPrefixBeforeLastS(string fileName, StringComparison comp)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName)) return string.Empty;
|
||||
|
||||
// 1) 去掉扩展名
|
||||
int dot = fileName.LastIndexOf('.');
|
||||
string noExt = dot >= 0 ? fileName.Substring(0, dot) : fileName;
|
||||
|
||||
// 2) 找最后一次出现 "-S"
|
||||
int pos = noExt.LastIndexOf("-S", comp);
|
||||
return pos >= 0 ? noExt.Substring(0, pos) : noExt;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:移动到目标表格</para>
|
||||
|
||||
Reference in New Issue
Block a user