Browse Source

Misc

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.4.2.1
Syrone Wong 7 years ago
parent
commit
9e529361c4
1 changed files with 13 additions and 6 deletions
  1. +13
    -6
      shadowsocks-csharp/Controller/FileManager.cs

+ 13
- 6
shadowsocks-csharp/Controller/FileManager.cs View File

@@ -5,7 +5,7 @@ using System.Text;
namespace Shadowsocks.Controller namespace Shadowsocks.Controller
{ {
public class FileManager
public static class FileManager
{ {
public static bool ByteArrayToFile(string fileName, byte[] content) public static bool ByteArrayToFile(string fileName, byte[] content)
{ {
@@ -17,8 +17,7 @@ namespace Shadowsocks.Controller
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Exception caught in process: {0}",
ex.ToString());
Logging.Error(ex);
} }
return false; return false;
} }
@@ -48,10 +47,18 @@ namespace Shadowsocks.Controller
public static string NonExclusiveReadAllText(string path, Encoding encoding) public static string NonExclusiveReadAllText(string path, Encoding encoding)
{ {
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var sr = new StreamReader(fs, encoding))
try
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var sr = new StreamReader(fs, encoding))
{
return sr.ReadToEnd();
}
}
catch (Exception ex)
{ {
return sr.ReadToEnd();
Logging.Error(ex);
throw ex;
} }
} }
} }


Loading…
Cancel
Save