4
3

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.

レシート情報取得時に UnauthorizedAccessException

Last updated at Posted at 2014-11-27

FileStream で直接開こうとするとタイトルの例外が発生するので、WWWクラスを使ってレシートデータを取得する。

sample.cs
	IEnumerator GetReceiptDataFromUrl(string url, Action<byte[]> callback) {
		using(WWW www = new WWW(url)) {
			yield return null;
			while (!www.isDone) {
				yield return null;
			}
			
			byte[] data = www.bytes;
			Debug.Log ("receiptData : " + data.ToHexString());
			
			callback(data);
		}
	}
	

ちなみに、String.ToHexString() は以下のような拡張メソッド

public static class Extensions {
	public string ToHexString(this byte[] binary) {
		return BitConverter.ToString(binary).ToLower().Replace("-","");
	}
}
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?