Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Exists意外返回false_C#_.net - Fatal编程技术网

C# Exists意外返回false

C# Exists意外返回false,c#,.net,C#,.net,我正在使用VLC打开C格式应用程序中的视频文件。在下面的代码中,File.Exists始终返回false,尽管该文件存在于给定路径中。但是,如命令行所示,当我手动给出路径时,文件被打开。string.Format处理没有问题,我已经在调试模式下检查了很多次,我从string.Format获得了正确的路径,但是File.exists返回false 1代码 fileName = string.Format(@"\\192.168.12.25\secRecords\{6}\{7}\{0:00}{1:0

我正在使用VLC打开C格式应用程序中的视频文件。在下面的代码中,File.Exists始终返回false,尽管该文件存在于给定路径中。但是,如命令行所示,当我手动给出路径时,文件被打开。string.Format处理没有问题,我已经在调试模式下检查了很多次,我从string.Format获得了正确的路径,但是File.exists返回false

1代码

fileName = string.Format(@"\\192.168.12.25\secRecords\{6}\{7}\{0:00}{1:00}{2:00}\CAM{5}_{0:00}{1:00}{2:00}_{3:00}{4:00}.mp4", (dateTimePicker1.Value.Year % 100),
                                                                                (dateTimePicker1.Value.Month),
                                                                                dateTimePicker1.Value.Day,
                                                                                dateTimePicker1.Value.Hour,
                                                                                (dateTimePicker1.Value.Minute / 15) * 15, myStr[1], splittedIp[2], splittedIp[3]);
        //fileName = @"\\192.168.12.25\secRecords\3\4\140617\CAM1_140617_1300.mp4"; 
        if (File.Exists(fileName))
        {
            id = axVLCPlugin21.playlist.add(fileName);
            trackBar1.Value = 0;
        }
        else
        {
            id = -1;
            MessageBox.Show("File not found!");
        }
调试模式下的文件名值:

"\\\\192.168.12.25\\secRecords\\3\\4\\140617\\CAM1_140617_1300.mp4"

splittedIp[3]以未知非法字符RS结束,通过从字符串中删除未知字符来解决问题

splittedIp[3] = splittedIp[3].Remove(splittedIp[3].Length - 1);

使用FileInfo会在路径中返回非法字符。我认为这与解决UNC路径问题无关。手动指定的路径有效。是否排除了权限问题?应用程序使用与您的用户相同的凭据运行,并且有权访问路径?