1
1
// File: SafeNotes/Utilities.cs
2
2
using System ;
3
3
using System . IO ;
4
+ using System . Linq ;
4
5
5
6
namespace SafeNotes
6
7
{
@@ -10,27 +11,16 @@ private void UpdateEntriesCountAndSaveToFile()
10
11
{
11
12
// Update the savedEntriesCount label
12
13
SavedEntriesCount . Text = "Saved entries: " + EntriesListBox . Items . Count . ToString ( ) ;
13
-
14
- string exeDirectory = AppDomain . CurrentDomain . BaseDirectory ;
15
- string filePath = Path . Combine ( exeDirectory , "entries.txt" ) ;
16
-
17
- // Now save all entries to a txt file in the location of the application's .exe
18
- string [ ] entries = new string [ EntriesListBox . Items . Count ] ;
19
- for ( int i = 0 ; i < EntriesListBox . Items . Count ; i ++ )
20
- {
21
- // Do not include "ListViewItem:" in the txt file, instead say Entry # and the number of the entry
22
- entries [ i ] = EntriesListBox . Items [ i ] . ToString ( ) . Replace ( "ListViewItem: {" , "" ) . Replace ( "}" , "" ) ;
23
- }
24
- System . IO . File . WriteAllLines ( filePath , entries ) ;
25
14
}
26
15
27
16
private string FindManagerPath ( string managerName )
28
17
{
29
18
string [ ] paths = {
30
- "C:\\ Program Files\\ " + managerName + " \\ " + managerName + ".exe" ,
31
- "C:\\ Program Files (x86)\\ " + managerName + " \\ " + managerName + ".exe"
19
+ Path . Combine ( "C:\\ Program Files" , managerName , managerName + ".exe" ) ,
20
+ Path . Combine ( "C:\\ Program Files (x86)" , managerName , managerName + ".exe" )
32
21
} ;
33
22
23
+ // Check in Program Files and Program Files (x86)
34
24
foreach ( string path in paths )
35
25
{
36
26
if ( File . Exists ( path ) )
@@ -39,6 +29,18 @@ private string FindManagerPath(string managerName)
39
29
}
40
30
}
41
31
32
+ // Check AppData\Local and all subdirectories
33
+ string appDataPath = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , managerName ) ;
34
+ if ( Directory . Exists ( appDataPath ) )
35
+ {
36
+ string [ ] exeFiles = Directory . GetFiles ( appDataPath , "*.exe" , SearchOption . AllDirectories )
37
+ . Where ( f => Path . GetFileName ( f ) . ToLower ( ) . Contains ( managerName . ToLower ( ) ) )
38
+ . ToArray ( ) ;
39
+ if ( exeFiles . Length > 0 )
40
+ {
41
+ return exeFiles [ 0 ] ;
42
+ }
43
+ }
42
44
return null ;
43
45
}
44
46
@@ -47,31 +49,31 @@ private string GetManagerArgs(string managerName)
47
49
switch ( managerName )
48
50
{
49
51
case "Bitwarden" :
50
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
52
+ return "--password" + UserPassword . Text ;
51
53
case "KeePass Password Safe 2" :
52
- return "\" -user= \" " + UserPassword . Text + " \" - pw=\" " + UserConfirmPassword . Text + "\" " ;
54
+ return "\" - pw=\" " + UserPassword . Text + "\" " ;
53
55
case "1Password" :
54
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
56
+ return "--password" + UserPassword . Text ;
55
57
case "LastPass" :
56
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
58
+ return "--password" + UserPassword . Text ;
57
59
case "ProtonPass" :
58
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
60
+ return "--password" + UserPassword . Text ;
59
61
case "NordPass" :
60
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
62
+ return "--password" + UserPassword . Text ;
61
63
case "Dashlane" :
62
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
64
+ return "--password" + UserPassword . Text ;
63
65
case "Zoho Vault" :
64
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
66
+ return "--password" + UserPassword . Text ;
65
67
case "RoboForm" :
66
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
68
+ return "--password" + UserPassword . Text ;
67
69
case "Sticky Password" :
68
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
70
+ return "--password" + UserPassword . Text ;
69
71
case "Keeper" :
70
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
72
+ return "--password" + UserPassword . Text ;
71
73
case "Enpass" :
72
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
74
+ return "--password" + UserPassword . Text ;
73
75
case "Total Password" :
74
- return "--username " + UserPassword . Text + " -- password " + UserConfirmPassword . Text ;
76
+ return "--password" + UserPassword . Text ;
75
77
default :
76
78
return null ;
77
79
}
0 commit comments