- 最後登錄
- 2024-11-16
- 在線時間
- 146 小時
- 註冊時間
- 2008-12-30
- 閱讀權限
- 20
- 精華
- 0
- UID
- 5557651
- 帖子
- 274
- 積分
- 262 點
- 潛水值
- 31082 米
| 我想要讓VB.NET 存檔為 .DAT
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim s, d, f, g, h As String
- s = "REG_SZ"
- d = "REG_DWORD"
- f = "REG_BINARY"
- g = "REG_MULTI_SZ"
- h = "REG_EXPAND_SZ"
- '------------------RegClass--------------------
- '------------------Create Record------------------
- If Dir("C:\Reg Record") = "" Then
- System.IO.Directory.CreateDirectory("C:\Reg Record")
- End If
- '------------------Create Record------------------
- '------------Create VB6 Object "Wshshell"-----------
- Dim WshShell
- WshShell = CreateObject("WScript.Shell")
- '------------Create VB6 Object "Wshshell"-----------
- '------------Declare Some Variable------------
- Dim a, b, c As String
- a = TextBox1.Text
- b = TextBox2.Text
- c = TextBox3.Text
- '------------Declare Some Variable------------
- '----------------Create Reg With RegClass Option----------------
- If RadioButton1.Checked = True Then
- WshShell.RegWrite("" & a, "" & b, "" & s)
- My.Computer.Registry.SetValue("" & a, "" & b, "" & c.ToString)
- Dim Y As String = Now.Year.ToString, M As String = Now.Month.ToString, DD As String = Now.Day.ToString, AllDateStr As String = Y & " Year " & M & " Mouth " & DD & " DAY"
- Dim IntDatWithStr As Integer
- AllDateStr = CInt(IntDatWithStr)
- Dim Buffrtr(100000) As Byte
- Dim CreateRegPath As String = AllDateStr & " Create" & a & "\" & c
- Dim record As New FileStream("C:\Reg Record\CreatRegRecord.dat", FileMode.Create)
- Dim Writer As IAsyncResult = record.BeginWrite(Buffrtr, 0, CreateRegPath, Nothing, Nothing)
- End If
複製代碼
它已經產生 .DAT檔了
問題來了
- If RadioButton1.Checked = True Then
- WshShell.RegWrite("" & a, "" & b, "" & s)
- My.Computer.Registry.SetValue("" & a, "" & b, "" & c.ToString)
- Dim Y As String = Now.Year.ToString, M As String = Now.Month.ToString, DD As String = Now.Day.ToString, AllDateStr As String = Y & " Year " & M & " Mouth " & DD & " DAY"
- Dim IntDatWithStr As Integer
- AllDateStr = CInt(IntDatWithStr)
- Dim Buffrtr(100000) As Byte
- Dim CreateRegPath As String = AllDateStr & " Create" & a & "\" & c
- Dim record As New FileStream("C:\Reg Record\CreatRegRecord.dat", FileMode.Create)
- Dim Writer As IAsyncResult = record.BeginWrite(Buffrtr, 0, CreateRegPath, Nothing, Nothing)
- End If
複製代碼
我想將 今天的 "年 月 日 新增登入檔的名稱 " 都寫入 .DAT 檔裡面
但都沒寫成功 都擲回 System.InvalidCastException
FileStream
... |
|