以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 求助:怎么实现文件管理器增加文件之前就获取选中文件的名称,并解析成拼音。 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91889) |
-- 作者:李孝春 -- 发布时间:2016/10/21 10:23:00 -- 求助:怎么实现文件管理器增加文件之前就获取选中文件的名称,并解析成拼音。 求助:怎么实现文件管理器增加文件之前就获取选中文件的名称,并解析成拼音。 Dim dr As DataRow = e.DataRow If dr.IsNull("description1") Or Dr.IsNull("date") Then MessageBox.Show("文件描述和日期不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True Else e.SubFolder = "Attachments" & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year End If 上述代码已经实现地址的组合自定义, path结果为:Attachments\\ni hao a\\2016\\2016年技术科2.5假期安排表.xls 想把红色部分也生成拼音有什么办法呢? 或者是增加一个在文件列写入文件之前,就选择的文件的名称的获取,然后再解析为拼音,怎么操作呢? 请各位大大多多指导 谢谢!
[此贴子已经被作者于2016/10/21 10:33:58编辑过]
|
-- 作者:有点蓝 -- 发布时间:2016/10/21 10:34:00 -- Dim dr As DataRow = e.DataRow If dr.IsNull("description1") Or Dr.IsNull("date") Then MessageBox.Show("文件描述和日期不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True Else Dim f() As String = e.FileName.Split(".") e.FileName = GetPY(dr("description1")) & dr("date").Year & GetPY(f(0)) & "." & f(1) End If |
-- 作者:李孝春 -- 发布时间:2016/10/21 10:43:00 -- 回复:(有点蓝)Dim dr As DataRow = e.DataRowIf dr... 谢谢,经过比对 下面两个写法都可以实现同样的效果! Dim dr As DataRow = e.DataRow If dr.IsNull("description1") Or Dr.IsNull("date") Then MessageBox.Show("文件描述和日期不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True Else Dim f() As String = e.FileName.Split(".") \'e.FileName = "Attachments" & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year & "\\" & GetPY(f(0)) & "." & f(1) e.SubFolder = "Attachments" & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year & "\\" & GetPY(f(0)) & "." & f(1) End If
|
-- 作者:李孝春 -- 发布时间:2016/10/21 12:31:00 -- 回复:(有点蓝)Dim dr As DataRow = e.DataRowIf dr... 加上红色代码定义到项目文件下 结果出错,提示 .NET Framework 版本:2.0.50727.5485 Foxtable 版本:2016.7.29.1 错误所在事件: 详细错误信息: 不支持给定路径的格式。 Dim dr As DataRow = e.DataRow If dr.IsNull("description1") Then MessageBox.Show("文件描述不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True Else Dim f() As String = e.FileName.Split(".") e.FileName = ProjectPath & "Attachments" & "\\" & GetPY(dr("suitDocNumber")) & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year & "\\" & GetPY(f(0)) & "." & f(1) End If
|
-- 作者:有点蓝 -- 发布时间:2016/10/21 14:09:00 -- Dim dr As DataRow = e.DataRow If dr.IsNull("description1") Then MessageBox.Show("文件描述不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) e.Cancel = True Else Dim f() As String = e.FileName.Split(".") e.FileName = ProjectPath & "Attachments" & "\\" & GetPY(dr("suitDocNumber")) & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year & "\\" & GetPY(f(0)) & "." & f(1) msgbox(e.FileName) \'看看真实的路径 End If
|
-- 作者:李孝春 -- 发布时间:2016/10/21 14:22:00 -- 回复:(有点蓝)Dim dr As DataRow = e.DataRowIf dr... 提示如下: |
-- 作者:有点蓝 -- 发布时间:2016/10/21 14:56:00 -- GetPY(dr("suitDocNumber"))是空值,所以Attachments后面变成了2个\\\\ 所有参与生成名称的字段都要判断是否为空
|
-- 作者:李孝春 -- 发布时间:2016/10/21 15:18:00 -- 回复:(有点蓝)GetPY(dr("suitDocNumber"))是空值,... 经检查 不为空值时 只有一个\\ 但是还是错误提示一样 |
-- 作者:有点蓝 -- 发布时间:2016/10/21 15:38:00 -- e.FileName = "\\" & GetPY(dr("suitDocNumber")) & "\\" & GetPY(dr("description1")) & "\\" & dr("date").Year & "\\" & GetPY(f(0)) & "." & f(1) |
-- 作者:李孝春 -- 发布时间:2016/10/21 17:04:00 -- 回复:(有点蓝)e.FileName = "\" &... 谢谢 之前那样操作都是可以实现的 是不是新版本优化了这些操作呢? |