forked from cyberofficial/Synthalingua_Wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileOperations.vb
More file actions
77 lines (68 loc) · 3.03 KB
/
Copy pathFileOperations.vb
File metadata and controls
77 lines (68 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Imports System.IO
Public Class FileOperations
Public Class ScriptFileInfo
Public Property ScriptPath As String
Public Property FolderPath As String
Public Property ShortcutType As String
Public Sub New(scriptPath As String, folderPath As String, shortcutType As String)
Me.ScriptPath = scriptPath
Me.FolderPath = folderPath
Me.ShortcutType = shortcutType
End Sub
End Class
Public Shared Function InitializeCookiesFolder(currentDirectory As String) As Boolean
Try
Dim cookiesFolderPath As String = Path.Combine(currentDirectory, "cookies")
If Not Directory.Exists(cookiesFolderPath) Then
Directory.CreateDirectory(cookiesFolderPath)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Shared Function RefreshCookiesList(cookiesComboBox As ComboBox) As Boolean
Try
cookiesComboBox.Items.Clear()
Dim cookiesFolderPath As String = Path.Combine(Application.StartupPath, "cookies")
If Directory.Exists(cookiesFolderPath) Then
For Each file As String In Directory.GetFiles(cookiesFolderPath)
cookiesComboBox.Items.Add(Path.GetFileNameWithoutExtension(file))
Next
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Shared Function FindScriptFile(currentDirectory As String) As ScriptFileInfo
Dim scriptFilePath As String = Path.Combine(currentDirectory, "transcribe_audio.exe")
If File.Exists(scriptFilePath) Then
Return New ScriptFileInfo(scriptFilePath, Path.GetDirectoryName(scriptFilePath), "Portable")
End If
scriptFilePath = Path.Combine(currentDirectory, "transcribe_audio.py")
If File.Exists(scriptFilePath) Then
Return New ScriptFileInfo(scriptFilePath, Path.GetDirectoryName(scriptFilePath), "Source")
End If
Return New ScriptFileInfo(String.Empty, String.Empty, String.Empty)
End Function
Public Shared Sub EditWordBlockList(scriptLocation As String, wordBlockListLocation As String)
Try
If Not File.Exists(wordBlockListLocation) Then
Try
File.Create(wordBlockListLocation).Close()
Catch ex As Exception
MessageBox.Show("An error occurred while creating the file: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
End If
Try
Process.Start("notepad.exe", wordBlockListLocation)
Catch ex As Exception
MessageBox.Show("An error occurred while opening the file: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class