2013-12-13 50 views

回答

2

檢查這篇文章:http://chriskoenig.net/2011/08/19/upload-files-from-windows-phone/

private void task_Completed(object sender, PhotoResult e) 
     { 
      if (e.TaskResult != TaskResult.OK) 
       return; 

      const int BLOCK_SIZE = 4096; 

      Uri uri = new Uri("http://localhost:4223/File/Upload", UriKind.Absolute); 

      WebClient wc = new WebClient(); 
      wc.AllowReadStreamBuffering = true; 
      wc.AllowWriteStreamBuffering = true; 

      // what to do when write stream is open 
      wc.OpenWriteCompleted += (s, args) => 
      { 
       using (BinaryReader br = new BinaryReader(e.ChosenPhoto)) 
       { 
        using (BinaryWriter bw = new BinaryWriter(args.Result)) 
        { 
         long bCount = 0; 
         long fileSize = e.ChosenPhoto.Length; 
         byte[] bytes = new byte[BLOCK_SIZE]; 
         do 
         { 
          bytes = br.ReadBytes(BLOCK_SIZE); 
          bCount += bytes.Length; 
          bw.Write(bytes); 
         } while (bCount < fileSize); 
        } 
       } 
      }; 

      // what to do when writing is complete 
      wc.WriteStreamClosed += (s, args) => 
      { 
       MessageBox.Show("Send Complete"); 
      }; 

      // Write to the WebClient 
      wc.OpenWriteAsync(uri, "POST"); 
     } 

而且這二: Upload image using ASP.NET WebAPI using a model http://blog.anthonybaker.me/2013/06/how-to-upload-file-from-windows-phone.html

+0

我按照所有的步驟,但我其實是一個問題,這是這樣的,我是如何得到我的遠程服務器ip地址和港口? VAR fileUploadUrl = @ 「HTTP:// /文件上傳」; – user3064311

+0

我在哪裏可以其他我的這個「」http:// localhost:4223/File/Upload「」我買了一個叫www.comevox.com的域名,我怎麼知道端口號?該路徑/文件/上傳是服務器中的文件夾? – user3064311

相關問題