codequest
asked on
Get VS2013 to release a text file
In Win7 VS2013 asp.net, I want to use a text file to provide a variable to my web site, so that I can change the variable externally to the site during run time, to cause the site to run different code paths based on the variable.
But I get a "file in use" message when I try to update the text file.
Any suggestions on how to get around this, or to otherwise create the same effect, would be appreciated.
But I get a "file in use" message when I try to update the text file.
Any suggestions on how to get around this, or to otherwise create the same effect, would be appreciated.
Public Shared Function GetTestVar1(ByRef varVarName As String) As String
Dim rtn As String = ""
Dim rtnVal As String = "not found"
'-----------------------------------
Dim p1 As Integer = 0
Dim p2 As Integer = 0
Dim l1 As Integer = 0
Dim varFilePath As String
varFilePath = "D:\1015_AMPTK_205_BIZ_DEV_TARG\3100_Support\TestVar.txt"
Dim varWriter As StreamWriter
Dim wrkFile As FileStream
Try
wrkFile = New FileStream(varFilePath, FileMode.Open, FileAccess.Read)
Catch
Return "$ERR$ReadTestVarFile$26797541$FilePath =" & varFilePath
Exit Function
End Try
Dim wrkFileReader As StreamReader = New StreamReader(wrkFile)
Dim n As Integer = 0
Dim inLine As String
'----------------------------Read
While (wrkFileReader.Peek > -1)
inLine = wrkFileReader.ReadLine
If InStr(inLine, varVarName) <> 0 Then
p1 = InStr(inLine, "=")
If p1 <> 0 Then
l1 = Len(inLine)
rtnVal = Mid(inLine, p1 + 1, l1 - p1 + 1)
End If
End If
End While
'--------------------------------
wrkFileReader = Nothing
wrkFile = Nothing
Return rtnVal
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER