|
//Read the image stream by specifying projectname.imagename
Stream imageStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("GettingStarted.Xamarin_JPEG.jpg");
|
|
Platform |
Code example |
|
Android |
public Stream LoadFromFile(string fileName)
{
string root = null;
if (Android.OS.Environment.IsExternalStorageEmulated)
{
root = Android.OS.Environment.ExternalStorageDirectory.ToString();
}
else
root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
return System.IO.File.OpenRead(root+"/Syncfusion/"+fileName.ToString());
}
Note: The input image file should be in Syncfusion folder.
|
|
iOS |
public Stream LoadFromFile(string filename)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string filePath = Path.Combine(path, filename);
return System.IO.File.OpenRead(filePath)
}
Note: The input image file should be in MyDocument folder.
|
|
UWP |
public stream LoadFromFile(string fileName)
{
LoadFile1(filename).Result;
}
public async Task<Stream> LoadFile1(string filename)
{
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.GetFileAsync(filename);
Stream outStream = await sampleFile.OpenStreamForReadAsync();
return outStream;
}
Note: The input image file should be in Current.LocalFolder location.
|