我有以下课程。 我想在完成计算时提出一个事件。 但是VS-2015告诉我“如果没有类方法的显式实例,你可能不会引用类的实例成员。”。
有谁能告诉我这里出了什么问题以及如何解决这个问题? 我想每个班级都可以举办活动。
谢谢!
Imports System.Text
Imports System.IO
Imports Microsoft.Win32
Imports NAudio.Wave
Namespace VoiceRecorder.Audio
Public Class AudioSaver
Public Event Finished()
Private _sInputPath As String
Public Property _tsTrimFromStart As TimeSpan
Public Property _tsTrimFromEnd As TimeSpan
' Public Property _sffSaveFileFormat As SaveFileFormat
Public Property _sLameExePath As String
Public Sub New(ByVal uInputPath As String)
Me._sInputPath = uInputPath
End Sub
Public ReadOnly Property IsTrimNeeded As Boolean
Get
Return _tsTrimFromStart <> TimeSpan.Zero OrElse _tsTrimFromEnd <> TimeSpan.Zero
End Get
End Property
Public Sub SaveAudio(ByVal uOutputPath As String)
Dim sTempFiles As New List(Of String)
Dim sPathToProcess = _sInputPath
If IsTrimNeeded() Then
Dim sTempFile As String = WavFileUtils.GetTempWavFileName()
sTempFiles.Add(sTempFile)
WavFileUtils.TrimWavFile(_sInputPath, sTempFile, _tsTrimFromStart, _tsTrimFromEnd)
sPathToProcess = sTempFile
End If
' If _sffSaveFileFormat = SaveFileFormat.Mp3 Then
ConvertToMp3(Me._sLameExePath, sPathToProcess, uOutputPath)
'Else
' File.Copy(sPathToProcess, uOutputPath, True)
'End If
DeleteTempFiles(sTempFiles)
End Sub
Private Sub DeleteTempFiles(ByVal tempFiles As IEnumerable(Of String))
For Each tempFile In tempFiles
If File.Exists(tempFile) Then
File.Delete(tempFile)
End If
Next tempFile
End Sub
Public Shared Sub ConvertToMp3(ByVal lameExePath As String, ByVal waveFile As String, ByVal mp3File As String)
Dim nConverter = Process.Start(lameExePath, "-V2 """ & waveFile & """ """ & mp3File & """")
nConverter.WaitForExit()
RaiseEvent Finished()
End Sub
End Class
End Namespace
答案 0 :(得分:0)
知道了。我不得不删除&#34;共享&#34;属性,但我仍然不知道为什么会这样。