序列号激活 [英] Serial Number Activation
问题描述
我已经制作了序列号激活程序,试图在我的硬盘驱动器位置C:\try中找到* .txt文件。如果它找到它的名称是包含序列号文本框中的文本的文件。问题是在第9行我采取了这个异常:发生了AmbiguousMatchException。参数值无法转换为'ReadAllCollection(OfString to'Char'。有人可以帮忙吗?下面你看到代码:
I've made a serial number activation program which tries to find a *.txt file in my hard drive location C:\try. If it locates the file that it's name is the which contains the text from the serial number textbox. The problem is that on the 9th line I take this exception: AmbiguousMatchException occurred. The parameter value cannot be converted to from 'ReadAllCollection(OfString to 'Char'. Can someone please help? Below you see the code:
Public Class Form1
Private Sub UnlockButton_Click(sender As Object, e As EventArgs) Handles UnlockButton.Click
Dim SearchThere As Object = My.Computer.FileSystem.GetDirectories("C:\try")
Dim SearchWithinThis As String = SerialNumber.Text
Dim SearchForThis As String = SerialNumber.Text
Dim FirstCharacter As String = SearchWithinThis.IndexOf(SearchForThis)
Dim Location As Integer = FirstCharacter.IndexOf(SearchThere) 'here is the problem
Dim todaysdate As String = String.Format("{0:dd/MM/yyyy}", DateTime.Now)
If SerialNumber.Text = My.Computer.FileSystem.ReadAllText(Location) Then
Form2.Show()
My.Computer.FileSystem.WriteAllText(Location, Environment.NewLine, True)
My.Computer.FileSystem.WriteAllText(Location, "successful access:",True)
My.Computer.FileSystem.WriteAllText(Location, Space(2), True)
My.Computer.FileSystem.WriteAllText(Location, todaysdate, True)
My.Computer.FileSystem.WriteAllText(Location, Space(1), True)
My.Computer.FileSystem.WriteAllText(Location, TimeOfDay, True)
Else
Form3.Show()
My.Computer.FileSystem.WriteAllText(Location, Environment.NewLine, True)
My.Computer.FileSystem.WriteAllText(Location, "access denied:", True)
My.Computer.FileSystem.WriteAllText(Location, Space(2), True)
My.Computer.FileSystem.WriteAllText(Location, todaysdate, True)
My.Computer.FileSystem.WriteAllText(Location, Space(1), True)
My.Computer.FileSystem.WriteAllText(Location, TimeOfDay, True)
End If
End Sub
End Class
请帮帮我吗?
这是实验性的。我的真正目标是让程序连接到我的网站并从中获取* .txt文件我使用此代码:
Please can you help me?
That is experimental. My real goal is to make the program connect to my website and take the *.txt files from I use this code:
Dim URL As String = "www.example.com"
Dim request As HttpWebRequest = WebRequest.Create(URL)
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
但是我得到了一个URI异常。如果有人可以帮助我,那么我将被迫。
But I get an URI exception. If someone can help me in this too then I would be obliged.
推荐答案
GetDirectories返回一个字符串集合:你不能用它来搜索一个字符实例!
这就是忽略你在同一个字符串中搜索字符串的索引,
GetDirectories returns a collection of strings: you can't use that to search for a character instance!
And that is ignoring that you are searching for the index of a string, within the same string,
Dim SearchWithinThis As String = SerialNumber.Text
Dim SearchForThis As String = SerialNumber.Text
Dim FirstCharacter As String = SearchWithinThis.IndexOf(SearchForThis)
返回一个整数值,该值始终为零。
然后你尝试在其中搜索(如一个字符串)来查找stri中的位置ng值0是一个字符串集合!
停止你正在做的事情,回到起点,想想你想要实现的目标 - 因为我完全不知道那是什么,但我确定你不会像那样靠近它!
which returns an integer value which will always be zero.
And you then try to search within that (as a string) to find where in the string value "0" a collection of strings is located!
Stop what you are doing, go back to the start, and think about what you are trying to achieve - because I have absolutely no idea what that is, but I am damn sure that you aren't going to get anywhere near it like that!
这篇关于序列号激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!