欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vb.net讀配置文件,vb 配置文件

vb.net中,讀取和寫入文件

寫入:Dim sr As New IO.StreamWriter(Application.StartupPath "/寫入的文本.txt")

香河網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,香河網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為香河近千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的香河做網(wǎng)站的公司定做!

sr.WriteLine("寫入的內(nèi)容") sr.Close()讀取:If (File.Exists(Application.StartupPath "/msg.txt")) Then

Dim fm As New IO.FileStream(Application.StartupPath "/讀取的文本.txt", FileMode.Open)

Dim sr As IO.StreamReader = New IO.StreamReader(fm)

Do While sr.Peek() = 0

TextBox1.Text = sr.ReadLine() (讀取文本到文本框)

Loop end if

vb.net 2.0 如何用Configuration.ConfigurationSettings.AppSettings讀取配置文件中的內(nèi)容?

使用ConfigurationSettings.AppSetting讀取,如下例

Imports System.Configuration

Private ReadOnly db As String = ConfigurationSettings.AppSettings("DB")

vb.net如何讀取服務(wù)器上的文件。把文件讀出來……

樓上的繼續(xù)忽悠人吧。2,3句搞定的東西弄這么復(fù)雜。。。

就是讀取服務(wù)器文件呀。

微軟論壇就有例子。

Imports System

Imports System.IO

Class Test

Public Shared Sub Main()

Try

' 創(chuàng)建一個實例的StreamReader閱讀從一個文件。

Dim sr As StreamReader = New StreamReader("TestFile.txt")

Dim line As String

' 閱讀并顯示線路從文件,直到最后

' 該文件被達(dá)成。

Do

line = sr.ReadLine()

Console.WriteLine(Line)

Loop Until line Is Nothing

sr.Close()

Catch E As Exception

' 讓用戶知道有什么地方出了差錯。

Console.WriteLine("The file could not be read:")

Console.WriteLine(E.Message)

End Try

End Sub

End Class

//上面是微軟的例子,你可以參考自己改,下面是我改的。

Imports System.IO

Partial Class test

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Using sr As StreamReader = New StreamReader("E:\新建文本文檔.txt", Encoding.GetEncoding("gb2312"))

Response.Write(sr.ReadLine())

End Using

End Sub

End Class

已經(jīng)測試過了,文件路徑自己改,支持TXT格式,其他格式自己修改編碼

求大神指點 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("配置設(shè)置已經(jīng)成功!?。。?)

Catch ex As Exception

MsgBox("錯誤?。。?!")

End Try

End Sub

VB.NET2010讀取INI配置文件問題?

設(shè)計功能

說明:第一個參考頁導(dǎo)入了System.IO

功能sdGetIniInfo(字符串的BYVAL iniSection的字符串,BYVAL INIFILE),如果該字符串/ File.Exists (INIFILE返回的“文件”INIFILE的的)

,而“未找到,以確保路徑和文件名是否正確!”如果

黑暗iniRead

昏暗的iniStr新的StreamReader(INIFILE),的字符串iniRead.ReadToEnd

朦朧朦朧的整數(shù)

最后的出口,克萊因整數(shù)

昏暗的NOSEC布爾=假

作為一個字符的字符串昏暗的getValue“

黑暗的壁櫥

衣柜iniStr.Split(CHR(13 ))CLINE = UBOUND功能的(CLST)

= 0 CLINE

衣柜(I)的indexOf(“=”) 0,

衣柜(I)分裂(“=”) (0)TRIM()= iniSection

NOSEC =

的getValue = CLST(I)分裂(“=”;)(1)修剪()

BR /退出

最后,如果

如果NOSEC = TRUE

返回的getValue BR /

的安裝信息沒有找到“iniSection!”

功能

====如果=================== ===================

TEXT1 = sdGetIniInfo(路徑,“名稱”)

事實上,無論是ini文本文件XML只使用一定的格式,或所謂的數(shù)據(jù)結(jié)構(gòu),在最后的分析中,實現(xiàn)的文件操作的功能只是一個包文件的讀取和寫入操作。

是不是寫一個函數(shù)的API!

當(dāng)前標(biāo)題:vb.net讀配置文件,vb 配置文件
文章URL:http://chinadenli.net/article48/heihhp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站設(shè)計公司品牌網(wǎng)站建設(shè)、微信公眾號、靜態(tài)網(wǎng)站企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)