2017-11-21 14 views
0

xamarin.formsで任意のタイプのファイルをデバイスにダウンロードすることができるかどうか疑問に思っていました.DeファイルはAzureに保存されています。ファイルのMemorystreamを取得します私のアプリ。私の質問は2部実際には、 ユーザーのデバイスにファイルをダウンロードする方法、 とタイプの既定のアプリケーション(PDFリーダーのような)の任意の種類のファイルを表示する方法memorystreamを使ってデバイスにファイルを保存する

これはです何を試しましたか

MemoryStream memoryStream = AzureDownloader.DownloadFromAzureBlobStorage(null、doc.azure_container、doc.fileure、ref.fileure、true);

string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); 
    string localFilename = doc.filename; 
    string localPath = Path.Combine(documentsPath, localFilename); 
    File.WriteAllBytes(localPath, memoryStream.ToArray()); // this is a try to save to local storage 

任意のヘルプは、ユーザーのデバイスにファイルをダウンロードする方法を

答えて

0

を高く評価しましたか?

そのクロスプラットフォームとして使用PCLStorageとiOSとAndroidのために働くだろう:

PDFリーダーのようなタイプ (のデフォルトのアプリケーション内のすべての種類のファイルを表示する方法
public async Task CreateRealFileAsync() 
{ 
    // get hold of the file system 
    IFolder rootFolder = FileSystem.Current.LocalStorage; 

    // create a folder, if one does not exist already 
    IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists); 

    // create a file, overwriting any existing file 
    IFile file = await folder.CreateFileAsync("MyFile.txt", CreationCollisionOption.ReplaceExisting); 

    // populate the file with some text 
    await file.WriteAllTextAsync("Sample Text..."); 
} 

これは広すぎて、達成したいことに応じていくつかの解決策があります。これは

+0

に役立ちます。しかし、これは唯一のtxtファイルのためのものです

ホープ..私は、PDFファイルのように、ファイルの任意のタイプかもしれない... –

+0

それはpdfファイルのために動作します。パスとファイル名が正しい限り。たとえば、_ "fileName.pdf" _ –

+0

を使用できますが、それは共有プロジェクトで機能しますか?それはまた、Excelファイルのために働くのですか? –

関連する問題