-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexecHandle.cs
More file actions
43 lines (39 loc) · 1.51 KB
/
execHandle.cs
File metadata and controls
43 lines (39 loc) · 1.51 KB
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
37
38
39
40
41
42
43
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace sshAutoConnect
{
class execHandle
{
public void recreatePuttyResource()
{
Assembly currentAssembly = Assembly.GetExecutingAssembly();
string[] arrResources = currentAssembly.GetManifestResourceNames();
foreach (string resourceName in arrResources)
{
if (resourceName == "sshAutoConnect.putty.exe")
{
string saveAsName = resourceName;
FileInfo fileInfoOutputFile = new FileInfo(System.IO.Path.GetTempPath() + saveAsName);
if (!fileInfoOutputFile.Exists)
{
FileStream streamToOutputFile = fileInfoOutputFile.OpenWrite();
Stream streamToResourceFile = currentAssembly.GetManifestResourceStream(resourceName);
const int size = 4096;
byte[] bytes = new byte[4096];
int numBytes;
while ((numBytes = streamToResourceFile.Read(bytes, 0, size)) > 0)
{
streamToOutputFile.Write(bytes, 0, numBytes);
}
streamToOutputFile.Close();
streamToResourceFile.Close();
}
}
}
}
}
}