0

I'm using VLC to open video files in C# form application. In my code as you see below "File.Exists" always returns false, although the file exists in the given path. But, as seen in the commanded line, when I give the path manually the file gets opened. There's no problem in string.Format processing, I have checked it in debug mode many time, I get the right path from string.Format but still File.exists returns false.

1) Code

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!");
        }

fileName value in debug mode:

"\\\\192.168.12.25\\secRecords\\3\\4\\140617\\CAM1_140617_1300.mp4"
John Saunders
  • 160,644
  • 26
  • 247
  • 397
nekorawesh
  • 11
  • 3
  • Using FileInfo returns illegal characters in path. I don't think it's related to resolving UNC path problem. The manually given path works. – nekorawesh Jun 17 '14 at 16:45
  • You've ruled out the case of a permissions issue? The app is running under the same credentials as your user and has access to the path? – Mike Guthrie Jun 17 '14 at 18:15

1 Answers1

0

splittedIp[3] was finishing with an unknown (illegal) character RS, the problem is solved by removing the unknown character from string.

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