Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is causing NotSupportedException ("The given path's format is not supported") while using a valid path?

Tags:

c#

.net

I am writing a simple console application that will read xml from a test file and deserialize it to an object.

var s = File.ReadAllBytes("‪G:\\Temp\\Publishing\\2.txt");
Stream _response = File.OpenRead("‪G:\\Temp\\Publishing\\2.txt");
var s = File.ReadAllBytes(@"‪g:\temp\publishing\2.txt");
var s = File.ReadAllBytes(@"‪G:\Temp\Publishing\2.txt");

I have tried all of the above to read the file and it always throws NotSupportedException with a message

The given path's format is not supported.

What is the format-error in the above path?

like image 652
Libin TK Avatar asked Jul 21 '14 02:07

Libin TK


1 Answers

According to the reference source: http://referencesource.microsoft.com/#mscorlib/system/io/filestream.cs#732

NotSupportedException will be thrown if the index of the : in your path is at the third position or later. (One would expect : to be the second character) Are you sure there are no zero-width combining characters or other similar Unicode shenanigans going on in your source?

like image 124
Billy ONeal Avatar answered Oct 05 '22 22:10

Billy ONeal