How to download an image from a user computer

Can I upload an image to an XNA game from a user computer? For example, I want to download "C: \ Images \ Box.png" to create a texture. Is it possible? If so, how?

+6
source share
2 answers

In XNA 4.0 use Texture2D.FromStream

 Texture2D fileTexture; using(FileStream fileStream = new FileStream(@"C:\Images\Box.png", FileMode.Open)) { fileTexture = Texture2D.FromStream(GraphicsDevice, fileStream); } 

If you use XNA before 4.0, you can use Texture2D.FromFile .

+14
source
 System.IO.FileStream stream = new System.IO.FileStream(@"C:\Images\Box.png", System.IO.FileMode.Open); Texture2D texture = Texture2D.FromStream(GraphicsDevice, stream); 
+5
source

Source: https://habr.com/ru/post/900713/


All Articles