从文件名中删除单引号 [英] Remove Single Quot From Filename
问题描述
我正在vb.net 2008 Windows App中编写以下代码.
私人Sub ExpTrk()
试试
昏暗的FNtrk作为字符串
FNtrk = txtReptrkfile.Text
如果dmlobj.con.State = ConnectionState.Closed然后
dmlobj.con.Open()
Dim sqltrkf As String =从NAGCM.dbo.RecTruck的位置选择Truck_No,Report_No,Rep_Date,Initial,其中Report_No ="&txtrepno.Text和""
昏暗的datrkf =新的SqlDataAdapter(sqltrkf,dmlobj.con)
Dim dstrkf As DataSet = New DataSet
datrkf.Fill(dstrkf,"RecTruck")
dstrkf.WriteXml("D:\ ExpData \"&FNtrk&"''.xml)
MsgBox(已导出数据,MsgBoxStyle.Information,"已导出数据)
dmlobj.con.Close()
如果结束
异常捕获
MsgBox(ex.Message.ToString)
结束尝试
结束子
========
现在的问题是,当我执行此代码时,我得到名称为txtReptrkfile.Text
的xml文件.
带双引号的示例
文本框的值就像11180
然后我得到文件名="11180"
我要删除这些引号
任何帮助将不胜感激
在Advance中致谢
I am Writing the below said code in vb.net 2008 Windows App.
Private Sub ExpTrk()
Try
Dim FNtrk As String
FNtrk = txtReptrkfile.Text
If dmlobj.con.State = ConnectionState.Closed Then
dmlobj.con.Open()
Dim sqltrkf As String = "Select Truck_No, Report_No,Rep_Date,Initial from NAGCM.dbo.RecTruck Where Report_No=''" & txtrepno.Text & "'' "
Dim datrkf = New SqlDataAdapter(sqltrkf, dmlobj.con)
Dim dstrkf As DataSet = New DataSet
datrkf.Fill(dstrkf, "RecTruck")
dstrkf.WriteXml("D:\ExpData\ ''" & FNtrk & "''.xml")
MsgBox("Data Exported , MsgBoxStyle.Information, "Data Export")
dmlobj.con.Close()
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
========
Now the problem is when i execute this code i get the xml file with name of txtReptrkfile.Text
With Double quotes for Example
The Textbox value is like 11180
Then i get the filename = ''11180''
I want to remove these quotes
Any Help will be highly appreciated
Thanks in Advance
推荐答案
从该行中删除引号-dstrkf.WriteXml("D:\ExpData\ ''" & FNtrk & "''.xml")
.
将其更改为dstrkf.WriteXml("D:\ExpData\" & FNtrk & ".xml")
.
Remove quotes from this line -dstrkf.WriteXml("D:\ExpData\ ''" & FNtrk & "''.xml")
.
Change it todstrkf.WriteXml("D:\ExpData\" & FNtrk & ".xml")
.
这篇关于从文件名中删除单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!