Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DSasse · Jan 30, 2018 at 12:07 PM · .netftp

Download from FTP with Hololens?

Hi everybody,

I would like to download files from a FTP-Server and do some magic with the data.

The application should run on the Microsoft Hololens. I am using Unity 2017.2 with the MixedRealityToolkit "2017.2.1.1 Patch Release".

In Unity everything works fine, but as soon as I try to build the application I receive 5 errors like: "The type or namespace name "FtpWebRequest" could not be found (are you missing a using directive orassembly reference?)"

I am using the Runtime Version "Experimental (.NET 4.6. Equivalent)" and the Api Compability Level ".NET 4.6"

This is the code of my main script:

 using UnityEngine;
 using System.IO;
 using System.Net;
 using System;
 
 
 public class UpdateFtfFtp : MonoBehaviour
 {
     public float JsonReadInterval = 1;
     public int AgvNumber;
 
     private const string Host = "ftp://192.168.2.101/";
     private string _remoteFileName;
     private string _localFileName;
 
     private const int bufferSize = 2048;
 
     // JSON coords are in mm, table dimension is 2000mm x 1000mm
     // Y axis on the table corresponds to Z axis on the map
     // 0, 0 is at -0.036, 0.442 (local) on the map
     // 2000, 1000 is at -0.526, 0.131 (local) on the map
     // (assuming real coords are in the center of the FTF)
     // This results in the following ratios for translating real to virtual coords
     private const float ZeroX = -0.036F;
     private const float ZeroY = 0.442F;
     private const float RatioX = -0.000245F;
     private const float RatioY = -0.000311F;
 
     private float _timer;
 
     // Use this for initialization
     public void Start()
     {
         _remoteFileName = "AGV" + AgvNumber + "Status.json";
         _localFileName = "Assets\\JsonStream\\" + _remoteFileName;
         LoadJsonData();
     }
 
     // Update is called once per frame
     public void Update()
     {
         _timer += Time.deltaTime;
 
         if (_timer >= JsonReadInterval)
         {
             LoadJsonData();
             _timer = 0;
         }
     }
 
     private void LoadJsonData()
     {
         DownloadJson();
 
         var jsonString = File.ReadAllText(_localFileName);
         var ftfData = FtfData.FromJson(jsonString, AgvNumber);
 
         transform.eulerAngles = new Vector3(0, 0, ftfData.Gyro);
         transform.localPosition = new Vector3(
             ZeroX + RatioX * ftfData.PosX,
             transform.localPosition.y,
             ZeroY + RatioY * ftfData.PosY
         );
     }
 
     private void DownloadJson()
     {
         var request = (FtpWebRequest)WebRequest.Create(Host + _remoteFileName);
         request.Credentials = new NetworkCredential("pi", "123");
         request.Method = WebRequestMethods.Ftp.DownloadFile;
         var response = (FtpWebResponse)request.GetResponse();
         var ftpStream = response.GetResponseStream();
         var localFileStream = new FileStream(_localFileName, FileMode.Create);
 
         var byteBuffer = new byte[bufferSize];
         var bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
 
         try
         {
             while (bytesRead > 0)
             {
                 localFileStream.Write(byteBuffer, 0, bytesRead);
                 bytesRead = ftpStream.Read(byteBuffer, 0, bufferSize);
             }
         }
         catch (Exception ex)
         {
             Debug.Log(ex.ToString());
         }
 
         localFileStream.Close();
         ftpStream.Close();
         response.Close();
         request = null;
     }
 }

Do you know if it's possible to request data from a FTP-Server with the Hololens?

All errors seem to be related to missing type or namespaces, in particular multiple errors from the System.Net namespace. Is it possible that I am missing a DLL or that the HoloLens does not support some libraries?

I am glad for any help. :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

75 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Issue With System.Net when Using FTP 1 Answer

Issue with TLS and X509 authentication 0 Answers

Problem with FileStream 1 Answer

30f + 0.5f = 30f What?????? 1 Answer

How to use System.Net with code stripping? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges