-
Notifications
You must be signed in to change notification settings - Fork 465
Expand file tree
/
Copy pathOpenExternalFile.cs
More file actions
36 lines (33 loc) · 945 Bytes
/
OpenExternalFile.cs
File metadata and controls
36 lines (33 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// opens external file in default viewer for that filetype
// for example: powerpoint file would open in powerpoint
using UnityEngine;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System;
using Debug = UnityEngine.Debug;
namespace UnityLibrary
{
public class OpenExternalFile : MonoBehaviour
{
// opens external file in default viewer
public static void OpenFile(string fullPath)
{
Debug.Log("opening:" + fullPath);
if (File.Exists(fullPath))
{
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = fullPath;
myProcess.Start();
// myProcess.WaitForExit();
}
catch (Exception e)
{
Debug.Log(e);
}
}
}
}
}