我使用带有"IsNullOrWhiteSpace(+ textbox)"的if条件来引用一个没有值或只有空格的文本.但是,现在我需要知道hot指定一个非空或仅空白的字段.
这是我写的代码:
if (string.IsNullOrWhiteSpace(pathofsrcfilesTOCOPY.Text))
Run Code Online (Sandbox Code Playgroud)
但是,如果我想指定只在textfield为null或为空时运行命令呢?
非常感谢您的帮助.我是初学者.感谢帮助.
祝你有美好的一天!
在我的工具中,我内置了一个功能,可以将文件从用户指定的位置复制到另一个位置.如果我复制并复制到基于网络驱动器的位置,那么单个2 kb文件大约需要10分钟才能复制.这不是一个网络问题,因为没有该工具就可以正常工作.
期望:将文件从一个网络位置复制到另一个网络位置的工具.
会发生什么:单个1 kb文件复制需要10分钟以上.如果我从本地驱动器到网络位置,或反之亦然,那就更好了.
这是我的复制代码:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
if (!string.IsNullOrWhiteSpace(fedPREVIEW.Text))
if (!string.IsNullOrWhiteSpace(pathofsrcfilesTOCOPY.Text))
if (!string.IsNullOrWhiteSpace(foldercreationPATH.Text))
{
for (int i = 1; i <= 100; i++)
{
string sourcePath = @pathofsrcfilesTOCOPY.Text;
string targetPath = foldercreationPATH.Text + "\\01_SR";
if (!Directory.Exists(targetPath))
{
Directory.CreateDirectory(targetPath);
}
//Copy the folders from sourcepath and place into mentioned target path,
//Overwrite the folder if same file is exist in target path
foreach (string srcPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories))
{
Directory.CreateDirectory(srcPath.Replace(sourcePath, targetPath));
}
//Copy the …Run Code Online (Sandbox Code Playgroud) 如果我使用:
if (MainTextBox.Text.Contains("red" + "blue"))
Run Code Online (Sandbox Code Playgroud)
然后,文本框必须包含这两个术语.但是,如何指定文本框以包含其中一个?