vb.net读写配置 vbnet读写文件

vb.net 中如何进行文件的读写一般来讲asp.net的服务器运行应用所用的账号只有对应用所在目录(放网页的目录)的访问权限,你可以把文件存储在应用所在目录或者子目录试试 。
【vb.net读写配置 vbnet读写文件】My.Computer.FileSystem.WriteAllText(Server.MapPath("")“\"Now.toString("yyyyMMdd")".txt", "URL:XXXXXX查询完成 , 匹配成功!"vbCrLf, true, System.Text.Encoding.Default)
vb.net 2.0 如何用Configuration.ConfigurationSettings.AppSettings读取配置文件中的内容?使用ConfigurationSettings.AppSetting读?。?如下例
Imports System.Configuration
Private ReadOnly db As String = ConfigurationSettings.AppSettings("DB")
求大神指点 vb.net 怎么读 ini 配置呢VB.NET读写INI配置文件
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String
path = Application.StartupPath + "\Send.ini"
TextBox1.Text = GetINI("Send", "Send1", "", path)
TextBox2.Text = GetINI("Send", "Send2", "", path)
Dim IsSms As Integer = GetINI("Send", "IsSms", "", path)
If (IsSms = 1) Then
Me.RadioButton1.Checked = True
ElseIf (IsSms = 0) Then
Me.RadioButton2.Checked = True
End If
End Sub
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
Dim Str As String = LSet(Str, 256)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
Public Function WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName)
End Function
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim path As String
path = Application.StartupPath + "\Send.ini"
WriteINI("Send", "Send1", TextBox1.Text, path)
WriteINI("Send", "Send2", TextBox2.Text, path)
If (Me.RadioButton1.Checked = True) Then
WriteINI("Send", "IsSms", 1, path)
ElseIf (Me.RadioButton2.Checked = True) Then
WriteINI("Send", "IsSms", 0, path)
End If
MsgBox("配置设置已经成功vb.net读写配置!vb.net读写配置!vb.net读写配置!vb.net读写配置!")
Catch ex As Exception
MsgBox("错误vb.net读写配置?。。。?)
End Try
End Sub
vb.net读写txt文件的问题这个用读写TXT的话比较繁琐 , 建议题主使用读写INI的方式 , 参考:
'声明INI配置文件读写API函数
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
'定义读取配置文件函数
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String

推荐阅读