VB.net中相关的使用从VB6转变过来
- 创建固定指定空间长度的字符串
VB6 dim str_tmp as string(1024)
VB.net中我是这样搞的
dim chr_tmp(1024) as char
dim str_tmp as string
str_tmp=chr_tmp
检查str_tmp的长度就是1025(str_tmp.lenth)
- 获取当前APP的路径
VB6 app.path
vb.net中是 Environment.CurrentDirectory
- 创建文件夹和文件(VB.NET)
Private Sub Create_Dir(Dir_Path As String)
Directory.CreateDirectory(Dir_Path)
End Sub
Private Sub Create_File(Full_Filename As String)
Dim tempdir() As String
Dim dirCreated As String
Dim count1 As Integer
Dim str_FileName As String
str_FileName = Trim(Full_Filename)
If Mid(str_FileName, str_FileName.Length - 1, 1) = "\" Then 'VB6中用Right在VB.NET中已经不好用了
Call Create_Dir(str_FileName)
Exit Sub
End If
tempdir = Split(str_FileName, "\")
dirCreated = ""
For count1 = 0 To UBound(tempdir) - 1
If tempdir(count1) <> "" Then
dirCreated = dirCreated & tempdir(count1) & "\"
End If
Next
Call Create_Dir(dirCreated)
If File.Exists(Full_Filename) = False Then
Dim fs As FileStream = File.Create(Full_Filename)
fs.Close()
End If
End Sub