|
|
|
@ -15,6 +15,7 @@ using System.Linq;
|
|
|
|
|
using System.Management;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
@ -37,6 +38,28 @@ namespace MediaBrowser.ServerApplication
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
|
|
|
static extern bool SetDllDirectory(string lpPathName);
|
|
|
|
|
|
|
|
|
|
public static bool TryGetLocalFromUncDirectory(string local, out string unc)
|
|
|
|
|
{
|
|
|
|
|
if ((local == null) || (local == ""))
|
|
|
|
|
{
|
|
|
|
|
unc = "";
|
|
|
|
|
throw new ArgumentNullException("local");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name FROM Win32_share WHERE path ='" + local.Replace("\\", "\\\\") + "'");
|
|
|
|
|
ManagementObjectCollection coll = searcher.Get();
|
|
|
|
|
if (coll.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
foreach (ManagementObject share in searcher.Get())
|
|
|
|
|
{
|
|
|
|
|
unc = share["Name"] as String;
|
|
|
|
|
unc = "\\\\" + SystemInformation.ComputerName + "\\" + unc;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unc = "";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines the entry point of the application.
|
|
|
|
|
/// </summary>
|
|
|
|
|