VB.NET Service unable to Write file to UNC location
Posted on 2006-05-24
Hello all at EE
I have a Class within a VB.NET service that needs to create a WAV file and write some header info into it onto a network share. I also need to have a form to interact with the service. I get the error, "Access denied" when writing the WAV file. This is because the service is running as local system and does not have access to the network share.
I havea dedicated network user that I can use to access the share but how do I do that in code, The class function is below.
A quick response to this would be fantastic I have a very tight timscale (Who doesnt) to finish this project.
Function processWavFile(ByRef strWavFile As Scripting.File, ByRef strSource As String, ByRef strDestination As String) As Boolean
On Error GoTo err_Renamed
Dim sTmp As Object
Dim tmpRecord As clsRecord
Dim ts As Scripting.TextStream
'read text file to get info and read it into a new record
tmpRecord = New clsRecord
strDestination = "\\server\networkshare"
tmpRecord.AUDIODESTINATION = strDestination & "\" & UserID & "_" & strWavFile.Name
ts = strWavFile.OpenAsTextStream(Scripting.IOMode.ForReading, Scripting.Tristate.TristateFalse)
Dim sWhole As String
sWhole = ts.Read(strWavFile.Size)
tmpRecord.BODY = Mid(sWhole, 9)
ts = Nothing
''''write the new wav file based on the record
'ERROR OCCURS HERE
processWavFile = True
Err.Raise(8002, , "error in WAV creation." & Err.Description)
processWavFile = False