[英]VB.NET Save data from textbox
我在將文本從TextBox保存到文件時遇到麻煩。
代碼>
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")
代替文本-> resources.GetString(“ httpdconf.Text”)<-
我不理解本文的內容。
(文本是預先指定的)-(文本不說用戶)
已修正,我將要保存的代碼保存到文件中,該程序將從該文件中獲取。 原因>啟動后加載大文本時程序擁塞
代碼>
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.