vb.netread的简单介绍

vb.net 操作文件夹用户权限'
' 需要添加以下命名空间:
' Imports System.IO
' Imports System.Security.AccessControl
' */
Dim sPath As String =Server.MapPath(文件夹名称字符串)
Directory.CreateDirectory(sPath)
addpathPower(sPath, "ASPNET", "FullControl")
'////////////////////////////////////////////////
PublicSub addpathPower(ByVal pathname As String, ByVal username As String, ByVal power As String)
Dim dirinfo As DirectoryInfo =New DirectoryInfo(pathname)
If (dirinfo.AttributesFileAttributes.ReadOnly)0 Then
dirinfo.Attributes = FileAttributes.Normal
End If
'取得访问控制列表
Dim dirsecurity As DirectorySecurity =dirinfo.GetAccessControl()
Select Case power
Case "FullControl"
dirsecurity.AddAccessRule(New FileSystemAccessRule(uername,FileSystemRights.FullControl,InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow))
Exit Sub
Case "ReadOnly"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Read,AccessControlType.Allow))
Exit Sub
Case "Write"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Write,AccessControlType.Allow))
Exit Sub
Case "Modify"
dirsecurity.AddAccessRule(New FileSystemAccessRule(username,FileSystemRights.Modify,AccessControlType.Allow))
Exit Sub
End Select
dirinfo.SetAccessControl(dirsecurity)
End Sub
vb.net2010十六进制读取串口的问题不是很明白你vb.netread的题意
strHex = strHex + [String].Format("{0:X2} "
这里vb.netread的意思是把每个字节数据转换成vb.netread了十六进制vb.netread,每个字节占两个字符
如果你串口收到vb.netread的4个字节数据:43,27,56,200
那么你的结果是:2B1B38C8
即receivebytes.Text="2B1B38C8"
不足两位的补0
如果你串口收到的4个字节数据:3,27,56,200
那么你的结果是:031B38C8
即receivebytes.Text="031B38C8"
VB.NET 获取文件MD5值Public Function md5(ByVal a As String) As String
Dim tempmd5 As System.Security.Cryptography.MD5 = New System.Security.Cryptography.MD5CryptoServiceProvider()
Dim bytResult() As Byte = tempmd5.ComputeHash(System.Text.Encoding.Default.GetBytes(a))
【vb.netread的简单介绍】Dim strResult As String = BitConverter.ToString(bytResult)
strResult = strResult.Replace("-", "")
Return strResult
End Function
如果要计算文件的就把参数改成字节数组就可以了,然后获取文件GetBytes()传进去就可以了 。
vb.net2005中提示无法在流的结尾之外进行读取我给你一个实例,你自己修改;
一,运行界面:
二,完整代码:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'写文件
Dim Myw As New FileStream(Application.StartupPath"\实验文件.txt", FileMode.Create)
Dim MyB_Write As BinaryWriter = New BinaryWriter(Myw)
MyB_Write.Write(TextBox1.Text)
Myw.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'读文件
Dim Myr As New FileStream(Application.StartupPath"\实验文件.txt", FileMode.Open, FileAccess.Read)
Myr.Position = 0
Dim MyB_Read As New BinaryReader(Myr)
Dim MyFileLength As Integer = CInt(Myr.Length - Myr.Position) - 1
Dim MyFileData(MyFileLength) As Char
MyB_Read.Read(MyFileData, 0, MyFileLength)
Myr.Close()
TextBox2.Text = ""
Dim i As Integer
For i = LBound(MyFileData) To UBound(MyFileData)
TextBox2.Text = TextBox2.TextMyFileData(i)
Next
End Sub
End Class
关于vb.netread和的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读