Reputation: 45771
I find when reading from a local file from Silverlight, we have to use special path separator "/" other than normal path separator "\" or else Silverlight can not get related local file, for example we need to write as c:/test/abc.wmv, other than write as c:\test\abc.wmv.
Two more questions,
Any simple solution to use normal file separator?
C# File/FileInfo class will use normal path separator to represent a file name (full path name), how to change all the normal path separator into this special path separator so that Silverlight could recognize?
I am using VSTS 2008 + C# + .Net 2.0.
thanks in advance, George
Upvotes: 0
Views: 1198
Reputation: 24385
You could use an Extension Method:
public string ToSilverlightPath(this string s)
{
return s.Replace("\\", "/");
}
or
public string ToSilverlightPath(this Path p)
{
return p.GetFullPath().Replace("\\", "/");
}
Edit:
After thinking about it some more Silverlight probably works with URIs'.
That is, all paths in Silverlight are URIs'.
So instead of using Path you should probably use Uri, like:
Uri mySilverlightPath = new Uri(myPathString);
or
Uri mySilverlightPath = new Uri(myPath.GetFullPath());
Not sure about this though but I guess it would make sense.
Upvotes: 2