3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OculusGoからWindows共有フォルダ(sambaサーバ, UNCパス)のファイルを読む方法

Last updated at Posted at 2018-08-13

OculusGoというか、androidをターゲットとしたunityアプリケーションでSambaサーバに接続してファイルを読み込む方法。
(とりあえずwindows共有フォルダのテキストファイルが読めるところまでしか試していないけれど、取っ掛かりにはなると思う)

環境: Unity 2018.1.5f1 (64-bit) Personal

事前準備

あらかじめ Assets/Plugins に
https://jcifs.samba.org/src/
からダウンロードした「jcifs-1.3.19.jar」をコピーしておく。

コード

以下のコードで、\192.168.XXX.XXX\share\test.txt の1行目の内容を読み込むことに成功した。

try {
	string user   = "user";
	string pass   = "pass";
	string server = "192.168.XXX.XXX";
	string path   = "share/test.txt";
	string smb = "smb://" + user + ":" + pass + "@" + server + "/" + path;

	using (AndroidJavaObject sfis = new AndroidJavaObject("jcifs.smb.SmbFileInputStream", smb))
	using (AndroidJavaObject inputSr = new AndroidJavaObject("java.io.InputStreamReader", new [] {sfis} ))
	using (AndroidJavaObject butterR = new AndroidJavaObject("java.io.BufferedReader"   , new [] {inputSr} )) {
		string line = butterR.Call<string>("readLine");

		MyOVRDebug.Log(line); // これは単にOculusGo上で文字表示するための自作関数
	}
} catch (System.Exception ex) {
	MyOVRDebug.Log(ex.ToString());
}

参考にしたURL

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?