AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
FileSystemHelper.cs
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License. See LICENSE in the project root for license information.
3
4
#if UNITY_EDITOR
5
using
UnityEngine
;
6
7
namespace
HoloToolkit
.Unity
8
{
12
public
static
class
FileSystemHelper
13
{
14
public
static
void
WriteBytesToLocalFile(
string
filename, byte[] content)
15
{
16
try
17
{
18
var fs =
new
System
.IO.FileStream(filename,
System
.IO.FileMode.Create);
19
var bw =
new
System
.IO.BinaryWriter(fs);
20
bw.Write(content);
21
bw.Close();
22
fs.Close();
23
}
24
catch
(
System
.Exception ex)
25
{
26
Debug
.LogError(
"Error writing to file: "
+ ex.ToString());
27
}
28
}
29
30
public
static
byte[] ReadBytesFromLocalFile(
string
fullPath)
31
{
32
var path = fullPath;
33
byte[] result = null;
34
try
35
{
36
var fs =
new
System
.IO.FileStream(path,
System
.IO.FileMode.Open);
37
var br =
new
System
.IO.BinaryReader(fs);
38
39
if
(fs.Length >
int
.MaxValue)
40
{
41
throw
new
System
.ArgumentOutOfRangeException();
42
}
43
44
result = br.ReadBytes((
int
)fs.Length);
45
br.Close();
46
fs.Close();
47
}
48
catch
(
System
.Exception ex)
49
{
50
Debug
.LogError(
"Read file exception: "
+ ex.ToString());
51
}
52
return
result;
53
}
54
}
55
}
56
#endif
System
Debug
HoloToolkit
UnityEngine
Assets
HoloToolkit
Utilities
Scripts
FileSystemHelper.cs
Generated by
1.8.12