对我来说是愚蠢的问题.我曾多次使用'*',但对于我的生活,我不记得如何.
示例:ComboBox1中的文本是iPad安装指南2015我想在代码中保持通用(所以如果它更改为2016)
我有以下代码:
If ComboBox1.Text = "iPad Setup Guide" Then
Run Code Online (Sandbox Code Playgroud)
我试过的代码:
If ComboBox1.Text = "iPad Setup Guide*" Then
If ComboBox1.Text = "iPad Setup Guide" + "*" Then
Run Code Online (Sandbox Code Playgroud)
我忘记了什么?
谢谢,
我正在尝试删除整个目录,但遇到问题。
问题
当尝试删除目录时,它不起作用。我知道 Stackoverflow 讨厌这个答案,但这是事实,没有错误。事实上,它给了我“成功”的信息。
这时候事情就变得棘手了。如果我在目录中创建一个文件夹并添加一些虚拟文件,它会起作用,但如果我将它与已经存在的文件夹一起使用,它不会将其删除。
Dim loc As String = "\\drtnas01\storeprofiles" 'Profile Location
Dim dfile As String = "\" & BatchTextBox.Text
Dim path As String = loc & dfile
VDIRebuildBG.ReportProgress(10, "Looking for Profile")
BatchStatusBox.Style = ButterscotchAlertBox.AlertStyle.Success
If Directory.Exists(path) Then
VDIRebuildBG.ReportProgress(20, "Profile Found")
BatchStatusBox.Style = ButterscotchAlertBox.AlertStyle.Success
Try
VDIRebuildBG.ReportProgress(30, "Starting Rebuild")
System.IO.Directory.Delete(path, True)
Catch
VDIRebuildBG.ReportProgress(100, "Error Rebuilding")
BatchStatusBox.Style = ButterscotchAlertBox.AlertStyle.Error
End Try
VDIRebuildBG.ReportProgress(100, "Profile Rebuilt")
BatchStatusBox.Style = ButterscotchAlertBox.AlertStyle.Success
Else
VDIRebuildBG.ReportProgress(100, "Profile Not Found")
BatchStatusBox.Style = ButterscotchAlertBox.AlertStyle.Error
Exit Sub
End If
Run Code Online (Sandbox Code Playgroud)
请注意,我有权限,因为我可以手动删除该文件夹。 …
我和我的同事都做编程.他在C#上创建了一个类,我正在努力将其转换为VB.NET.除了单行之外,我得到全班转换,此时我无法弄明白,所以想到一副新鲜的眼睛可能能找到我的错误.
原始C#代码
using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }))
Run Code Online (Sandbox Code Playgroud)
转换VB.NET代码
Using client = New HttpClient(New HttpClientHandler With {Key .AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate})
Run Code Online (Sandbox Code Playgroud)
错误 在对象初始化中初始化的字段或属性的名称必须以"."开头.
错误位于"密钥"下
最后一点:我使用了一个可怕的代码转换器,所以我不确定'key'来自哪里.
我正在尝试让应用程序查看文件是否包含文本的一部分.如果确实包含它,我需要将它放在一个字符串中(和/或显示它).
到目前为止,我有它的工作,只要说它是否被发现,但我不确定如何将结果转换为字符串.
Dim dir As String = "C:\test\"
Dim file As String()
file = IO.Directory.GetFiles(dir, "1234" & "_*")
If file.Length > 0 Then
'Found
Else
'Not Found
End If
Run Code Online (Sandbox Code Playgroud)
当我尝试添加像Dim FileName as string = file我得到的东西时
类型1维数组的值无法转换错误
或者当我Dim file As String()改为Dim file As String我时会得到同样的错误.
这应该是一整天最容易的问题!
我想看到的是如何压缩一些代码.
例:
If textbox.text = "0000" then
'do something
End If
If textbox.text = "0001" then
'do something
End If
Run Code Online (Sandbox Code Playgroud)
我想要做的是在1声明中.