• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
快乐小精灵
博客园    首页    新随笔    联系   管理    订阅  订阅
文件操作

一、文件

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#  

posted on 2009-05-12 16:23  快乐小精灵  阅读(167)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3