mirror of
https://github.com/kimmknight/remoteapptool.git
synced 2025-10-10 01:18:12 +00:00
Check if file is locked or not and present to end user if it is locked and by what.
Resulted in breaking some of my habits and putting a messagebox windows in libraries. Not my favorite thing, but it works. This helps debug issue 3, it does not resolve issue 3. To test it - open an office document (such as Word or Excel) and try to overwrite the office document with the RDP file including the office document extention (xls, xlsx, doc, docx, etc). The application will tell you that the file is locked, locked by Word/Excel/etc and the PID that is locking it just in case you have multiple copies of the application that is locking it open. A lot of the code was borrowed from Microsoft (https://code.msdn.microsoft.com/windowsapps/How-to-know-the-process-170ed5f3/sourcecode?fileId=151114&pathId=1558127374).
This commit is contained in:
@@ -24,6 +24,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RDPFileLib", "..\RDPFileLib
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RDPSign", "..\RDPSign\RDPSign.vbproj", "{57DABB69-B1D3-445F-91E7-B0412ABAC218}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LockChecker", "..\LockChecker\LockChecker.vbproj", "{029C010D-728B-4B87-B54A-08B2BBF49BD7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -54,6 +56,10 @@ Global
|
||||
{57DABB69-B1D3-445F-91E7-B0412ABAC218}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{57DABB69-B1D3-445F-91E7-B0412ABAC218}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{57DABB69-B1D3-445F-91E7-B0412ABAC218}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{029C010D-728B-4B87-B54A-08B2BBF49BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{029C010D-728B-4B87-B54A-08B2BBF49BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{029C010D-728B-4B87-B54A-08B2BBF49BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{029C010D-728B-4B87-B54A-08B2BBF49BD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@@ -268,10 +268,18 @@
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LockChecker\LockChecker.vbproj">
|
||||
<Project>{029c010d-728b-4b87-b54a-08b2bbf49bd7}</Project>
|
||||
<Name>LockChecker</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\RDP2MSILib\RDP2MSILib.vbproj">
|
||||
<Project>{e1cb5f9c-230f-4967-8f19-335f8e4a4906}</Project>
|
||||
<Name>RDP2MSILib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\RDP2MSI\RDP2MSI.vbproj">
|
||||
<Project>{1001a958-40db-4444-9cd7-09d1188072d1}</Project>
|
||||
<Name>RDP2MSI</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\RDPFileLib\RDPFileLib.vbproj">
|
||||
<Project>{258307d5-a407-4622-bf1a-bdca8e3d2faa}</Project>
|
||||
<Name>RDPFileLib</Name>
|
||||
|
@@ -1,5 +1,4 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports RemoteAppLib
|
||||
|
||||
Module RemoteAppFunction
|
||||
|
||||
@@ -99,7 +98,23 @@ Module RemoteAppFunction
|
||||
|
||||
Public Sub DeleteFiles(FilesArray As ArrayList)
|
||||
For Each dFile In FilesArray
|
||||
If My.Computer.FileSystem.FileExists(dFile) Then My.Computer.FileSystem.DeleteFile(dFile)
|
||||
Dim LockCheck As New LockChecker.LockChecker()
|
||||
Dim FileLocked As String
|
||||
Dim SkipFile As Boolean = False
|
||||
FileLocked = LockCheck.CheckLock(dFile)
|
||||
While Not (FileLocked = "No locks")
|
||||
If (MessageBox.Show("The file " + dFile + " is currently locked. Lock information:" + FileLocked + vbNewLine + "Do you want to try again?", "File Locked", MessageBoxButtons.YesNo) = DialogResult.Yes) Then
|
||||
FileLocked = LockCheck.CheckLock(dFile)
|
||||
Else
|
||||
MessageBox.Show("The following file will not be deleted:" + vbNewLine + dFile)
|
||||
SkipFile = True
|
||||
FileLocked = "No locks"
|
||||
End If
|
||||
End While
|
||||
If Not (SkipFile) Then
|
||||
If My.Computer.FileSystem.FileExists(dFile) Then My.Computer.FileSystem.DeleteFile(dFile)
|
||||
End If
|
||||
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
Reference in New Issue
Block a user