相关疑难解决方法(0)

Visual Studio代码终端,如何运行具有管理员权限的命令?

新版本1.2.0包含一个终端,但是当我尝试安装任何带有节点的包时,我得到了npm ERR!我经常解决的代码EPERM右键单击并以管理员身份运行它.那我怎么在vscode终端那样做呢?linux有sudo之类的东西吗?

vscode终端

windows npm visual-studio-code

50
推荐指数
4
解决办法
5万
查看次数

使用c#确定文件是否存在并解析UNC路径

我正在尝试编写一个函数来确定文件是否存在.这两种方法证明返回不一致的结果(fileExists()似乎提供了准确的结果,与isFileFound()相比,它返回​​误报 - 我试图创建实例时会发生异常).

protected bool isFileFound(string path, string fileName)
    {
        System.IO.FileInfo fi = null;

        bool found = false;
        try
        {
            fi = new System.IO.FileInfo(path + fileName);
            found = true;
        }
        catch (Exception e)
        {
            baselogger.Fatal(e.Message + " " + e.StackTrace + " \n" + path + fileName);
        }

        return found;
    }

    protected bool fileExists(string path, string pattern)
    {
        bool success = false;

        try
        {
            success = File.Exists(path + pattern);
        }
        catch (Exception e)
        {
            baselogger.Warn(e.Message + " " + e.StackTrace …
Run Code Online (Sandbox Code Playgroud)

c# filesystems

29
推荐指数
2
解决办法
6万
查看次数

为什么System.IO.File.Exists(字符串路径)返回false?

System.IO.File.Exists(string path)
Run Code Online (Sandbox Code Playgroud)

即使文件存在于指定路径上,也始终返回false.可能的解决方案是什么?

c# io file

29
推荐指数
6
解决办法
5万
查看次数

当路径太长时,File.Exists()错误地返回false

我目前正在研究一个遍历各种目录的程序,以确保使用特定文件File.Exists().

该应用程序声称某些文件实际上不存在,我最近发现此错误是由于路径太长.

我意识到有关SO的问题可以解决File.Exists()返回错误值的问题,但似乎没有解决这个特定问题.

重命名目录和文件以缩短路径实际上不是一个选项,所以我不知道该做什么.是否有解决此问题的解决方法?

使用中的代码没有什么特别之处(我已经删除了一些不相关的代码),但我会在下面包含它以防万一它有所帮助.

    private void checkFile(string path)
    {
        if (!File.Exists(path))
            Console.WriteLine("   *  File: " + path + " does not exist.");
    }
Run Code Online (Sandbox Code Playgroud)

.net c#

15
推荐指数
4
解决办法
2万
查看次数

无法访问映射网络驱动器上的文件

我有一个问题,我无法访问映射文件夹中的任何文件

我的驱动器 N: 映射到 \erpu9\clients\,我有 1.txt 文件,我正在尝试读取。

函数返回File.Exists(@"N:\1.txt")false,但File.Exists(@"\\erpu9\clients\1.txt")返回true。FileInfo.Exists 中也发生了同样的事情。

当我尝试运行时File.ReadAllLines(@"N:\1.txt")出现异常:找不到路径“n:\1.txt”的一部分,但File.ReadAllLines(@"\\erpu9\clients\1.txt")工作正常

我真的迷路了,有什么建议吗?

如果相关,我正在使用 Windows 10、VS2013

c#

3
推荐指数
1
解决办法
2934
查看次数

标签 统计

c# ×4

.net ×1

file ×1

filesystems ×1

io ×1

npm ×1

visual-studio-code ×1

windows ×1