/// <summary> /// Checks whether or not a server is sharing a device. /// </summary> /// <param name="servername"> /// Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the /// function is to execute. If this parameter is NULL, the local computer is used. /// </param> /// <param name="localpath">Pointer to a string that specifies the name of the device to check for shared access.</param> /// <param name="shareType"> /// Pointer to a variable that receives a bitmask of flags that specify the type of the shared /// device. This parameter is set only if the function returns successfully. /// </param> /// <returns>Return a NetError Enumeration.</returns> public static Enum.NetError Exists(string servername, string localpath, out Enum.ShareType shareType) { uint type = 0; var result = (Enum.NetError) Internal.Native.NetworkShareManagementFunctions.NetShareCheck.DllImports.NetShareCheck(servername, localpath, out type); shareType = (Enum.ShareType) type; return result; }
/// <summary> /// Send file to recycle bin /// </summary> /// <param name="path">Location of directory or file to recycle</param> /// <param name="flags">FileOperationFlags to add in addition to FOF_ALLOWUNDO</param> internal static bool Send(string path, Enum.FileOperationFlags flags) { try { var fs = new ShFileOpStruct { wFunc = Enum.FileOperationType.FO_DELETE, pFrom = path + '\0' + '\0', fFlags = Enum.FileOperationFlags.FOF_ALLOWUNDO | flags }; var nativeShFileOpStruct = ShFileOpStruct.MapToNativeShFileOpStruct(fs); DllImports.SHFileOperation(ref nativeShFileOpStruct); return true; } catch (Exception) { return false; } }
/// <summary> /// Send file silently to recycle bin. Surpress dialog, surpress errors, delete if too large. /// </summary> /// <param name="path">Location of directory or file to recycle</param> public static bool MoveToRecycleBin(string path, Enum.FileOperationFlags flags) { return Send(path, flags); }