小编Pra*_*tik的帖子

在switch case中,如果我们将"default"写为任何单词或单个字母,则不会引发错误

在a中switch,如果我们写任何单词或单个字母而不是default 它不会抛出错误.例如

switch(10)
{
    case 1:
    break;

    hello:
    break;
}
Run Code Online (Sandbox Code Playgroud)

它运行时没有抛出错误.

谁能解释一下这是如何工作的?

c# switch-statement

15
推荐指数
3
解决办法
394
查看次数

File.exists() 为本地帐户中的服务返回 false

我有在本地系统帐户下运行的 Windows 服务。我正在检查 File.Exist(网络中的文件)。这适用于用户帐户,但它在本地系统帐户中为 file.exists() 返回 false。我无法使用用户帐户运行服务。提前致谢。

protected override void OnStart(string[] args) {
  m_objLogFile.LogError("******************Servicestarted*****************", "", "");
  Thread th = new Thread(new ThreadStart(StartIndexing));
  th.Start(); 
} 
private void StartIndexing() 
{ 
  bool bVal = File.Exists(@"100.100.1.1\f\Files\abc.txt"); 
}
Run Code Online (Sandbox Code Playgroud)

c# windows-services network-protocols

2
推荐指数
1
解决办法
1348
查看次数