大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
可以查看附件,或则使用以下代码。应该注释的满全了。
创新互联专注于伊犁企业网站建设,响应式网站开发,购物商城网站建设。伊犁网站建设公司,为伊犁等地区提供建站服务。全流程定制网站设计,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
随便建一个窗口工程,窗口代码帖入以下代码。
Imports System.IO
Imports System.Text
Imports System.Reflection
Public Class Form1
Const ResName As String = "123.txt" ' 需要保存的资源名
Const BufferSize As Integer = 4096 ' 复制时缓冲的大小
Private Sub Demo()
' 变量声明
Dim strDisplayText As StringBuilder ' 保存输出信息
Dim strResName As String ' 保存目标资源的名称
' 变量初始化
strDisplayText = New StringBuilder()
strResName = String.Empty
' 获取所有资源
strDisplayText.AppendLine("文件中存在以下资源:")
For Each strName As String In Assembly.GetExecutingAssembly.GetManifestResourceNames()
strDisplayText.AppendLine(" " strName)
' 获得目标资源的全名
If strName.EndsWith("." ResName) Then
strResName = strName
End If
Next
' 目标资源不存在
strDisplayText.AppendLine()
If strResName = String.Empty Then
strDisplayText.AppendLine("抱歉,没有找名为""" ResName """的资源")
Else ' 复制资源的代码
' 打开资源文件,在End Using的时候自动关闭。
Using ms As UnmanagedMemoryStream = Assembly.GetExecutingAssembly.GetManifestResourceStream(strResName)
' 打开磁盘文件,在End Using的时候自动关闭。
Using fs As New FileStream("C:\" ResName, FileMode.Create)
' 变量声明
Dim Buffer(BufferSize - 1) As Byte ' 复制文件时的缓冲数组
Dim ReadCount As Integer ' 此次读取数据的数量
' 还有数据可以读取的情况,一直循环
ReadCount = ms.Read(Buffer, 0, BufferSize)
While ReadCount 0
fs.Write(Buffer, 0, ReadCount) ' 写入到磁盘文件
ReadCount = ms.Read(Buffer, 0, BufferSize)
End While
End Using
End Using
strDisplayText.AppendLine("文件已经复制完毕。")
End If
' 显示消息
MessageBox.Show(strDisplayText.ToString())
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Demo()
End
End Sub
End Class
一般来讲asp.net的服务器运行应用所用的账号只有对应用所在目录(放网页的目录)的访问权限,你可以把文件存储在应用所在目录或者子目录试试。
My.Computer.FileSystem.WriteAllText(Server.MapPath("") “\" Now.toString("yyyyMMdd") ".txt", "URL:XXXXXX查询完成,匹配成功!" vbCrLf, true, System.Text.Encoding.Default)
Dim da As New OleDb.OleDbDataAdapter(‘’输入2/3/4其中的答案)
Dim ds As New DataSet
da.Fill(ds, "Table1")
Dim dt As DataTable
dt = ds.Tables("Table1")
//2. Cmd.CommandText = "select 序号 from 账号 where 姓名='小李'"
//3. Cmd.CommandText = "select 序号 from 账号 where 姓名='小张'"
//4. Cmd.CommandText = "insert into 账号(姓名,年龄,性别,序号) values('张三','22','男','4')"
DataGridView1.DataSource = dt '建立datagridview来显示资料
myCn.Close()
你用的WriteLine, Line就是行,所以会加换行符
如果用Sw1.Write("....");就不会换行
前日在用SiSofare Sandra 测试硬盘性能时突发其想 用自己熟悉的VB NET测试行不行呢?具体怎么做呢?我们最感兴趣的是硬盘在最大负荷下持续的读取和写入速度 为了能够比较准确的测出平均速度 我决定采用先写入一个 GB的文件再读取出来的办法 考虑到不要让更多的任务花在循环上 我首先建立起一个足够大的缓冲区 然后往磁盘写入这个缓冲的内容 从而使硬盘达到最大的负荷 考虑到Windows的读取机制 硬盘测试不太准确 此程序的读取部分只能在第一次运行时使用 运行次数越多测试也不准确 而写入测试多次运行以后依然能够保持准确性 现在就开始动手 在VB NET中创建了一个控制台工程TestHarddisk 然后在Sub Main中写入下列程序 Sub Main()Dim I As Int Dim f As New FileStream( E:\BigFile big FileMode Create)Dim fw As New BinaryWriter(f)Dim fr As New BinaryReader(f)Dim Size As Int = * * File size = GBDim bufSize As Int = * * Buffer Size = MBDim jLast As Int = bufSize Dim j As Int Dim Bytes(bufSize) As ByteDim StartWrite As Date = Date NowConsole WriteLine( Write Start at { } StartWrite)Console WriteLine( Creating )For I = To Size Step bufSize GBfw Write(Bytes)NextDim EndWrite As Date = Date NowDim TimePassed As TimeSpan = EndWrite Subtract(StartWrite)Console WriteLine( Write End at { } EndWrite)Console WriteLine( Time passed:{ } TimePassed)Console WriteLine( Speed:{ } / TimePassed TotalSeconds)fw Flush()Dim StartRead As Date = Date NowConsole WriteLine( Read Start at { } StartRead)Console WriteLine( Reading )For I = To Size Step bufSizeBytes = fr ReadBytes(bufSize)NextDim EndRead As Date = Date NowTimePassed = EndRead Subtract(StartRead)Console WriteLine( Read End at { } EndRead)Console WriteLine( Time passed:{ } TimePassed)Console WriteLine( Read speed:{ } / TimePassed TotalSeconds)Console ReadLine()fw Close()End Sub现在测试 硬件配置 Athlon +(running at G)EPOX RDA + nForce 主板 DDR (running at MHz)ATA Seagate GB MB 软件配置 Windows Server Standard Edition全套最新的WHQL驱动程序Visual Studio 编译选择Realse模式 打开所有优化选项 第一次运行测试得写入速度 MB/s 第二次测得 MB/s 第三次 MB/s与Sisofare测试得的结果 MB/s相差不大 达到了理想的效果 然而读取测试就变态了 第一次 MB/s 与Sissofare测试多了 MB/s左右 第二次达到了 MB/s 第三次 MB/s 这和Windows的磁盘缓冲机制有关 看来作用还是蛮大的 当然 建议读取测试在重起电脑以后进行 lishixinzhi/Article/program/net/201311/13666
先引用 System.ManageMent
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim HDDDeviceQuery As New Management.SelectQuery("Win32_DiskDrive")
Dim HDDDeviceSearch As New Management.ManagementObjectSearcher(HDDDeviceQuery)
Dim HDDDeviceInfo As Management.ManagementObject
For Each HDDDeviceInfo In HDDDeviceSearch.Get()
ComboBox1.Items.Add("HDD Description: " HDDDeviceInfo("caption").ToString())
ComboBox1.Items.Add("HDD BytesPerSector: " HDDDeviceInfo("BytesPerSector").ToString())
'ComboBox1.Items.Add("HDD CompressionMethod: " HDDDeviceInfo("CompressionMethod").ToString())
ComboBox1.Items.Add("HDD Index: " HDDDeviceInfo("Index").ToString())
'ComboBox1.Items.Add("HDD InstallDate: " HDDDeviceInfo("InstallDate").ToString())
ComboBox1.Items.Add("HDD Manufacturer: " HDDDeviceInfo("Manufacturer").ToString())
ComboBox1.Items.Add("HDD Partitions: " HDDDeviceInfo("Partitions").ToString() Space(1) GetLastDev())
ComboBox1.Items.Add("HDD Size: " Int(Val(HDDDeviceInfo("Size").ToString()) / 2 ^ 30) " GBytes")
ComboBox1.Items.Add("HDD TotalCylinders: " HDDDeviceInfo("TotalCylinders").ToString())
ComboBox1.Items.Add("HDD TotalSectors: " HDDDeviceInfo("TotalSectors").ToString())
ComboBox1.Items.Add("HDD TracksPerCylinder: " HDDDeviceInfo("TracksPerCylinder").ToString())
ComboBox1.Items.Add("HDD TotalHeads: " HDDDeviceInfo("TotalHeads").ToString())
ComboBox1.Items.Add("HDD TotalTracks: " HDDDeviceInfo("TotalTracks").ToString())
ComboBox1.Items.Add("HDD SectorsPerTrack: " HDDDeviceInfo("SectorsPerTrack").ToString())
ComboBox1.Items.Add("HDD SCSILogicalUnit: " HDDDeviceInfo("SCSILogicalUnit").ToString())
Next
End Sub
Public Function GetLastDev() As String
GetLastDev = ""
Dim r As Short = My.Computer.FileSystem.Drives.Count
For i As Short = 0 To r - 1 Step 1
GetLastDev = GetLastDev My.Computer.FileSystem.Drives(i).Name ":"
Next
Return GetLastDev
End Function
End Class