我将文本从TextBox保存到文件时遇到了问题。
代码和GT;
If Not File.Exists(My.Application.Info.DirectoryPath() + "\httpd\conf\httpd.conf") Then
Using sw As StreamWriter = New StreamWriter(My.Application.Info.DirectoryPath() + "\httpd\conf\httpd.conf", False)
sw.Write(httpdconf.Text & My.Application.Info.DirectoryPath() & "\httpd" & httpdconf2.Text & My.Application.Info.DirectoryPath() & "\www" & httpdconf3.Text & My.Application.Info.DirectoryPath() & "\www" & httpdconf4.Text & My.Application.Info.DirectoryPath & "\cgi-bin" + httpdconf5.Text & My.Application.Info.DirectoryPath & "\cgi-bin" & httpdconf6.Text)
End Using
End If
问题是文本是在没有httpdconf.Text行的情况下保存的,程序认为文本是空的(即使没有)。甚至设计师看起来也很奇怪
例>
'
'httpdconf
'
Me.httpdconf.Location = New System.Drawing.Point(10, 68)
Me.httpdconf.Name = "httpdconf"
Me.httpdconf.Size = New System.Drawing.Size(77, 102)
Me.httpdconf.TabIndex = 15
Me.httpdconf.Text = resources.GetString("httpdconf.Text")
而不是text - > resources.GetString(“httpdconf.Text”)< -
我不明白案文的内容 (文本已预先指定) - (文本不说用户)
答案 0 :(得分:0)
固定 我把我要保存的代码放到一个文件中,程序将从该文件中获取。原因>在启动后加载大文本时程序拥塞
代码和GT;
Dim apache_1
Dim apache_2
Dim apache_3
Dim apache_4
Dim apache_5
Dim apache_6
Using sr1 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_1")
apache_1 = sr1.ReadToEnd
End Using
Using sr2 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_2")
apache_2 = sr2.ReadToEnd
End Using
Using sr3 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_3")
apache_3 = sr3.ReadToEnd
End Using
Using sr4 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_4")
apache_4 = sr4.ReadToEnd
End Using
Using sr5 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_5")
apache_5 = sr5.ReadToEnd
End Using
Using sr6 As StreamReader = New StreamReader(My.Application.Info.DirectoryPath() + "\default_conf\apache_6")
apache_6 = sr6.ReadToEnd
End Using
Using sw As StreamWriter = New StreamWriter(My.Application.Info.DirectoryPath() + "\httpd\conf\httpd.conf", False)
sw.Write(apache_1 & My.Application.Info.DirectoryPath() & "\httpd" & apache_2 & My.Application.Info.DirectoryPath() & "\www" & apache_3 & My.Application.Info.DirectoryPath() & "\www" & apache_4 & My.Application.Info.DirectoryPath & "\cgi-bin" + apache_5 & My.Application.Info.DirectoryPath & "\cgi-bin" & apache_6)
End Using