zoukankan      html  css  js  c++  java
  • VB.NET中 读取txt文件示例

                                    VB.NET中 读取txt文件

    1.所需命名空间

    Imports System.IO
    Imports System.Web
    

    2. 读取文件代码

    Dim fp As StreamReader
    Dim s As String
    fp = File.OpenText(HttpContext.Current.Server.MapPath(".\") & "Source.txt")
    s = fp.ReadToEnd
    fp.Close()
    

    3. 文件示例

    ''SCRAP-INSTRUMENT BOV'',
    ''SCRAP-INSTRUMENT BOH'',
    ''SCRAP-INSTRUMENT BOA'',
    ''SCRAP-INSTRUMENT BOM'',
    ''SCRAP-ROTARY BOV'',
    ''SCRAP-ROTARY BOH'',
    ''SCRAP-ROTARY BOA'',
    ''SCRAP-ROTARY BOM'',
    ''SCRAP-S STEM BOV'',
    ''SCRAP-SPL PAINT BOH'',
    ''SCRAP- T26 BOH''
    

      文件内容被读取为字符串类型,可以直接当初字符串使用。如:

    strBuilder.AppendLine(" AND MGD.Segment1 IN (" & s & ")')) MTORA")

     

  • 相关阅读:
    KVM安装以及远程连接
    开博客祭
    CQOI 2021
    琐记——学长们
    大事祭
    关于洛谷与博客园的博客的一些声明
    CSP-S 2020 & NOIP 2020 日记与游记
    调和级数
    快速乘
    二叉堆
  • 原文地址:https://www.cnblogs.com/Dannier/p/1957786.html
Copyright © 2011-2022 走看看