How do I open a WPF content stream?
Your problem is specific to WPF. See Method Application.GetContentStream
.
You will read that this method requires a relative URI. See WPF Files, Resources, Content, and Data .
a source to share
I think you will find that your problem is that Application.GetContentStream is meant to stream resources for the content of the data file that is in the specified Uri. That is, it is deployed along with the executable assembly.
If you look at: http://msdn.microsoft.com/en-us/library/aa970494(VS.90).aspx#Site_of_Origin_Files
You should find that the file: /// syntax as above is correct ... But if you are going to open them, you probably need some kind of switch to figure out how to get the stream:
FileInfo fileToSave;
if (!existingFile.IsFile)
throw new ArgumentException("Input URI must represent a local file path", "existingFile");
fileToSave = new FileInfo(existingFile.LocalPath);
return fileToSave.Open(/* Args based on your needs */)
And similarly, if it's a web URI:
if (!existingFile.Scheme.StartsWith("http"))
throw new ArgumentException("Input URI must represent a remote URL path", "existingFile");
// Do a WebRequest.Create call and attempt download... (Perhaps to MemoryStream for future use)
Hope it helps.
Andrew.
a source to share