2017-09-27 18 views
0

Base64でエンコードされたPDFファイルを取得したいと思います。 は、まず私はこの方法で私の携帯電話上でローカルにファイルを保存し、ファイルへのパスを返します。 Xamarin FormsブラウザでPDFを開きます

byte[] byteBuffer = Encoding.UTF8.GetBytes(pdfString); 

public string SaveBinary(string filename, byte[] bytes) 
     { 
      string filepath = GetFilePath(filename); 
      if (File.Exists((filepath))) 
      { 
       File.Delete(filepath); 
      } 
      File.WriteAllBytes(filepath, bytes); 

      return filepath; 
     } 

string GetFilePath(string filename) 
     { 
      return Path.Combine(GetDocsPath(), filename); 
     } 

     string GetDocsPath() 
     { 
      return System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); 

     } 

は、その後、私は、ブラウザでPDFを開こうが、何も起こりません。

string filename = DependencyService.Get<IFileWorker>().SaveBinary($"name.pdf", byteBuffer); 
       try 
       { 
        Device.OpenUri(new Uri(filename)); 

答えて

関連する問題