一、文件
1、读
Dim FileName As String
Dim fileId As Integer
fileId = FreeFile()
FileName = StrPath + "\**.txt"
Dim FS As New System.IO.FileStream(FileName, IO.FileMode.Open)
Dim SR As New System.IO.StreamReader(FS)
buffer = SR.ReadLine
SR.Close()
FS.Close()
2、写
Dim FileName As String
Dim fileId As Integer
fileId = FreeFile()
FileName = StrPath + "\dingzhi\route" & CStr(Route) & ".txt"
Dim FS As New System.IO.FileStream(FileName, IO.FileMode.Create)
Dim SW As New System.IO.StreamWriter(FS)
SW.WriteLine("BEGIN")
SR.Close()
FS.Close()
二、配置文件
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 Integer
Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
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 Integer, ByVal lpFileName As String) As Integer
Dim strTmp As String = LSet("123", 256)
GetPrivateProfileString("【里的】", "=左边", " ", strTmp, 40, StrPath & CStr("\**.INI"))
str = Trim_Asc0(strTmp)
ival= GetPrivateProfileInt("【里的】", "=左边", 0, StrPath & CStr("\**.INI"))
Call WritePrivateProfileString("【里的】", "=左边", StrPath & CStr("\**.INI"))
三、补充
File.Exists(Application.StartupPath + "\\**.txt") //判断文件是否存在 c#
File.Create(Application.StartupPath + "\\**.txt");//创建该文件 c#