}
}
- using (FileStream file = new FileStream (parts [0], FileMode.Open, FileAccess.Read, FileShare.Read)) {
+ string filename = parts [0];
+ if (Path.DirectorySeparatorChar == '/')
+ filename = filename.Replace ("\\", "/");
+
+ using (FileStream file = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
buffer = new byte [file.Length];
file.Read(buffer, 0, (int) file.Length);
}
if (type == typeof(System.Byte[]))
return buffer;
- if (type == typeof (Bitmap) && Path.GetExtension (parts [0]) == ".ico") {
+ if (type == typeof (Bitmap) && Path.GetExtension (filename) == ".ico") {
MemoryStream ms = new MemoryStream (buffer);
return new Icon (ms).ToBitmap ();
}
}
}
+ [Test]
+ public void ConvertFrom_Type_String_FilePathWithBackslashes ()
+ {
+ if (Path.DirectorySeparatorChar == '\\')
+ // non-windows test
+ return;
+
+ string fileContents = "foobar";
+ string fileName = "foo.txt";
+ string filePath = Path.Combine (_tempDirectory, fileName);
+ File.WriteAllText (filePath, fileContents);
+
+ filePath = _tempDirectory + "\\.\\" + filename;
+
+ string fileRef = filePath + ";" + typeof (string).AssemblyQualifiedName;
+ string result = _converter.ConvertFrom (fileRef) as string;
+ Assert.IsNotNull (result, "#A1");
+ Assert.AreEqual (result, fileContents, "#A2");
+ }
+
[Test]
public void ConvertFrom_Type_StreamReader ()
{