2012-11-28 75 views
1

我使用silverlight保存PNG文件。但我想将它保存在应用程序IMG文件夹中。我的代码如下:在Silverlight的应用程序图像文件夹中保存PNG文件

if (lastSnapshot != null) 
     { 
      string ImageName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() 
      + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".png"; 
      string filePath=System.IO.Path.Combine("~/Images/", "" + ImageName + ""); 
      using (var pngStream = GetPngStream(lastSnapshot)) 
      using (var file = File.Create(filePath)) 
      { 
       byte[] binaryData = new Byte[pngStream.Length]; 
       long bytesRead = pngStream.Read(binaryData, 0, (int)pngStream.Length); 
       file.Write(binaryData, 0, (int)pngStream.Length); 
       file.Flush(); 
       file.Close(); 
      } 

     } 

我想在silverlight中做到这一点。我可以做吗?我可以直接保存文件在应用程序文件夹中怎么做?我会感谢任何会帮助我的人。提前致谢。

Adjacent question of mine

+0

我在MainPage.xaml.cs中编写代码 – decoder

+0

Silverlight是一种客户端技术,它在客户端运行在浏览器中。你对应用程序文件夹有什么意义? – sphair

+0

我可以保存图像在服务器端。我有一个应用程序目录中的IMG文件夹。可以在这方面ajax帮助。 – decoder

回答

1

你必须提供一个Web服务或者在服务器端上传网址,并使用从Silverlight中的客户端。

Silverlight应用程序无法直接访问服务器的文件夹,因为Silverlight在客户端执行。

相关问题