Author Topic: Problem with VB plugin reading a text fil  (Read 11535 times)

Nico1854

  • Guest
Problem with VB plugin reading a text fil
« on: December 10, 2016, 03:05:31 AM »
I'm trying to build a plugin to take informations from P3D/FSX and passing them over to VA.

The way it works is :

1. Extract the data from FSUIPC with a .lua and create a .txt file every second (1000 mSec).
2. Have a VB plugin that copies the txt file to another txt file (to avoid the fact of having both the lua and the VB opening the same file at the same time).
3. Have a VA command that loops the VB pluggin and waits 1 second before reading it again.

My problem is that it sometimes stops working.

If I do not use VA, the first step does never crash. If I use VA it sometimes even stops the .lua from working. I don't know how to solve this issue but was thinking maybe that in the lua and in the VB I should add a check so that they do not try to open the txt file if it is allready opened. But I can't find how to do that.

Lua code :
Code: [Select]
while 1 do

-- Get all of the data we want to display
daytime = ipc.readUB(0x115E)
gnd = ipc.readUB(0x0366)
gs, tas, ias = ipc.readStruct(0x02B4, "3UD")


-- and convert it from FS units to units we like
gs = (gs * 3600) / (65536 * 1852)
tas = tas / 128
ias = ias / 128

-- Insert into a txt file
file = io.open("C:/Program Files (x86)/VoiceAttack/Apps/P3DBridge/P3DBridge.txt", "w")
file:write(daytime.."\n"..gnd.."\n"..gs.."\n"..tas.."\n"..ias)
file:close()

ipc.sleep(1000)

end

VB code :
Code: [Select]
   Public Shared Sub VA_Invoke1(vaProxy As Object)

        My.Computer.FileSystem.CopyFile("C:/Program Files x86)/VoiceAttack/Apps/P3DBridge/P3DBridge.txt", "C:/Program Files x86)/VoiceAttack/Apps/P3DBridge/P3DBridge2.txt", True)


        Dim objStreamReader As System.IO.StreamReader
        objStreamReader = New System.IO.StreamReader("C:/Program Files (x86)/VoiceAttack/Apps/P3DBridge/P3DBridge2.txt")

        Dim P3DDaytime As String
        P3DDaytime = objStreamReader.ReadLine()
        Convert.ToDecimal(P3DDaytime)
        vaProxy.SetDecimal("VADaytime", P3DDaytime)

        Dim P3DGround As String
        P3DGround = objStreamReader.ReadLine()
        Convert.ToDecimal(P3DGround)
        vaProxy.SetDecimal("VAGround", P3DGround)

        Dim P3DGs As String
        P3DGs = objStreamReader.ReadLine()
        Convert.ToDecimal(P3DGs)
        vaProxy.SetDecimal("VAGs", P3DGs)

        Dim P3DTas As String
        P3DTas = objStreamReader.ReadLine()
        Convert.ToDecimal(P3DTas)
        vaProxy.SetDecimal("VATas", P3DTas)

        Dim P3DIas As String
        P3DIas = objStreamReader.ReadLine()
        Convert.ToDecimal(P3DIas)
        vaProxy.SetDecimal("VAIas", P3DIas)

        objStreamReader.Close()

VA Command in attached picture

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #1 on: December 10, 2016, 03:38:05 AM »
I don't know how LUA handles IO calls, but since the VB plugin code is only reading the file, you shouldn't have to do a copy to avoid lock issue... if you open the file like this:

Code: [Select]
Using objFileStream = New IO.FileStream("C:/Program Files (x86)/VoiceAttack/Apps/P3DBridge/P3DBridge.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)
    Using objStreamReader = New IO.StreamReader(objFileStream)
     'rest of your code
    End Using
End Using

You should be fine, and reduce further disk activity (which is already a lot, once a second)

Note also that in your plugin code, you can use a FileSystemWatcher object to monitor the status of the above file, and act only when it is actually modified; this could happens continuosly, outside of VA_Invoke1(); you store the latest values in some structure and when  VA_Invoke1() actually happens, you simply returns them... this might spare you a loop in VA.

Last but not least: I would avoid writing the file directly into a "Program Files (x86)" subfolder, since Windows can get a bit finicky about that... in VB, it's super easy to get the temp folder path with IO.PAth.GetTempFolder(), if it is also feasible in the LUA code, i would try this too.
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #2 on: December 10, 2016, 06:46:18 AM »
Thank you for your help, I managed to do a flight with no bugs, great.

I used your recommandation opening the file ans also moved out from program files (x86).

About the FileSystemWatcher, will take a look at it but for the moement, I'm following altitude and speed for example and they change all the time.

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #3 on: December 10, 2016, 08:37:20 AM »
About the FileSystemWatcher, will take a look at it but for the moement, I'm following altitude and speed for example and they change all the time.
Sure, but the nice thing is that you get an event callback everytime it changes, so you don't need to do a loop with a 1 second pause...

Another small thing that could help make things faster and limit file access to a minimum: if you don't need to have a separate line for each value for other reasons, you could write the file like this:
Code: [Select]
file:write(daytime.."|"..gnd.."|"..gs.."|"..tas.."|"..ias)
and then parse with a single line read, something like

Code: [Select]
Using objFileStream = New IO.FileStream("xxx\P3DBridge.txt", IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)
    Using objStreamReader = New IO.StreamReader(objFileStream)
        Dim P3Dvalues As String()
       
        P3Dvalues = objStreamReader.ReadLine().Split("|")
       
        vaProxy.SetDecimal("VADaytime", Convert.ToDecimal(P3Dvalues(0)))
        vaProxy.SetDecimal("VAGround", Convert.ToDecimal(P3Dvalues(1)))
        vaProxy.SetDecimal("VAGs", Convert.ToDecimal(P3Dvalues(2)))
        vaProxy.SetDecimal("VATas", Convert.ToDecimal(P3Dvalues(3)))
        vaProxy.SetDecimal("VAIas", Convert.ToDecimal(P3Dvalues(4)))
    End Using
End Using
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #4 on: December 10, 2016, 02:37:17 PM »
So, with FileSystemWatcher, I can update the valus in Vb only when they have changed, ok.

That brings me to the following question: how will VA know that a value has changed and that this changment should start a command.

Simple example, when the altitude is above 10000, I want VA to say "Above 10000".

My idea is to have a variable in lua set to 0 below 10000 and set to 1 above. Only when this variable is set to 1, lua will update the txt file that Vb is watching. I'm missing the next step of updating VA and automaticaly executing a command.
« Last Edit: December 11, 2016, 12:38:56 AM by Nico1854 »

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #5 on: December 11, 2016, 05:36:26 AM »
I have changed the .txt file and the plugin on to 1 line and now I have a new problem, after some time looping, VA says :

UNABLE TO INVOKE PLUGIN DUE TU EXCEPTION: Object reference not set to an instance of an object.

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #6 on: December 12, 2016, 12:05:02 AM »
I have changed the .txt file and the plugin on to 1 line and now I have a new problem, after some time looping, VA says :

UNABLE TO INVOKE PLUGIN DUE TU EXCEPTION: Object reference not set to an instance of an object.

This happens when there is an unhandled exception in your plugin code.

There is an error somewhere that needs to be debugged; there are many "sanity checks" that were not present in the code above, for example:
Testing that the file is actually present, testing that the stream opening doesn't return an error for some reason, that the content is not empty and exactly in the format what you expect (5 different lines as in the original version or 1 single line with 4 separators in the new one) and so on...
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #7 on: December 12, 2016, 05:44:45 AM »
Ok, I've added a Try / Catch and display message error to findout what error arrives.

I'm now going to try to find out how to use the FileSystemWatcher. As said in previous post, I'm still missing to understand the next step of updating VA and automaticaly executing a command without having to loop Inside of VA.

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #8 on: December 14, 2016, 07:22:38 AM »
I have created 1 class with all VA script and VA_Invoke1().
I have created another class with the (component) filesystemwatcher that reads the text file once it has changed.

Obviously, I'm stuck with the next step.

How do I call the filesystemwatcher in the other class from within VA_Invoke1() and take the variables that have been set in the filesystemwatcher.

I'm going to try to find out but must admit that not beeing a programmer makes me take a lot of time for some things that are maybe easy to do.

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #9 on: December 14, 2016, 10:41:20 AM »
I have created 1 class with all VA script and VA_Invoke1().
I have created another class with the (component) filesystemwatcher that reads the text file once it has changed.

Obviously, I'm stuck with the next step.

How do I call the filesystemwatcher in the other class from within VA_Invoke1() and take the variables that have been set in the filesystemwatcher.
You can do this with a single class, if you want: declare a variable 'with event' where your VA_Invoke1() is... you should now have a bunch of new event handler available (look in the drop downs above the code editor)

Those events are fired every time the monitored files are created/chenged/deleted etc... so, you can store the values you need in some other structures of your choice, and when VoiceAttack triggers VA_Invoke1(), you already have the latest value from the file, and you don't need to fetch them again

Example:
Code: [Select]
Public Class MyVAClass

    Private Const watchedFile As String = "F:\Temp\P3DBridge.txt"

    'This will store the latest values from the file
    Private Shared currentFileValues As New Dictionary(Of String, Decimal)

    'This is the watcher object, declared 'WithEvents'... see code at the bottom
    Private Shared WithEvents watcher As New IO.FileSystemWatcher

    Public Shared Function VA_Id() As Guid
        '[...]
    End Function

    Public Shared Function VA_DisplayName() As String
        '[...]
    End Function

    Public Shared Function VA_DisplayInfo() As String
        '[...]
    End Function

    Public Shared Sub VA_Init1(vaProxy As Object)
        '[...]
        'Sets the directory and files to watch; since Filter is set with a specific file name,
        'and not a wildcard mask, only a single file will be monitored

        watcher.Path = IO.Path.GetDirectoryName(watchedFile)
        watcher.Filter = IO.Path.GetFileName(watchedFile)
        watcher.EnableRaisingEvents = True
    End Sub

    Public Shared Sub VA_Exit1(vaProxy As Object)
        '[...]
    End Sub

    Public Shared Sub VA_StopCommand()
        '[...]
    End Sub

    Public Shared Sub VA_Invoke1(vaProxy As Object)
        '[...]

        'The currentFileValues dictionary contains all the latest values, you can simply return them
        For Each kvp As KeyValuePair(Of String, Decimal) In currentFileValues
            vaProxy.SetDecimal(kvp.Key, kvp.Value)
        Next
    End Sub

    Private Shared Sub watcher_Changed(sender As Object, e As IO.FileSystemEventArgs) Handles watcher.Changed

        'This is the event fired every time file changes are committed to disk

        Using objFileStream = New IO.FileStream(watchedFile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)
            Using objStreamReader = New IO.StreamReader(objFileStream)
                Dim P3Dvalues As String()

                P3Dvalues = objStreamReader.ReadLine().Split("|"c)

                currentFileValues.Clear()
                currentFileValues.Add("VADaytime", Convert.ToDecimal(P3Dvalues(0)))
                currentFileValues.Add("VAGround", Convert.ToDecimal(P3Dvalues(1)))
                currentFileValues.Add("VAGs", Convert.ToDecimal(P3Dvalues(2)))
                currentFileValues.Add("VATas", Convert.ToDecimal(P3Dvalues(3)))
                currentFileValues.Add("VAIas", Convert.ToDecimal(P3Dvalues(4)))
            End Using
        End Using
    End Sub
End Class

"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #10 on: December 15, 2016, 03:14:41 AM »
I really thank you for your help.

I have set the script as you detailled but I get this error when building :

Severity   Code   Description   Project   File   Line   Suppression State
Warning   CA2202   Object 'objFileStream' can be disposed more than once in method 'P3DBridge.watcher_Changed(Object, FileSystemEventArgs)'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 162

Line 162 is the second "End using" of the Private shared Sub watcher_Changed

Also, I tried to add the with event... but not managed to script it properly.

I think that I'm not far from having all this working with all the help you provided me.

Here is what my code actually looks like :

Code: [Select]
Public Class P3DBridge

    Private Const watchedFile As String = "...\P3DBridge.txt"

    'This will store the latest values from the file
    Private Shared currentFileValues As New Dictionary(Of String, Decimal)

    'This is the watcher object, declared 'WithEvents'... see code at the bottom
    Private Shared WithEvents watcher As New IO.FileSystemWatcher

    Public Shared Function VA_DisplayName() As String
'...
    End Function

    Public Shared Function VA_Id() As Guid
'...
    End Function

    Public Shared Function VA_DisplayInfo() As String
'...
    End Sub

    Public Shared Sub VA_Init1(vaProxy As Object)

        Dim objStreamReader As System.IO.StreamReader
        objStreamReader = New System.IO.StreamReader(".../P3DBridgeInit.txt")

        Dim P3DSeason As String
        P3DSeason = objStreamReader.ReadLine
        Convert.ToDecimal(P3DSeason)
        vaProxy.SetDecimal("VASeason", P3DSeason)

        Dim P3DAirType As String
        P3DAirType = objStreamReader.ReadLine
        vaProxy.SetText("VAAirType", P3DAirType)

        Dim P3DAirModel As String
        P3DAirModel = objStreamReader.ReadLine
        vaProxy.SetText("VAAirModel", P3DAirModel)

        objStreamReader.Close()

        'Sets the directory and files to watch; since Filter is set with a specific file name,
        'and not a wildcard mask, only a single file will be monitored
        watcher.Path = IO.Path.GetDirectoryName(watchedFile)
        watcher.Filter = IO.Path.GetFileName(watchedFile)
        watcher.EnableRaisingEvents = True

    End Sub

    Public Shared Sub VA_Exit1(vaProxy As Object)
'...
    End Sub

    Public Shared Sub VA_Invoke1(vaProxy As Object)

        'The currentFileValues dictionary contains all the latest values, you can simply return them
        For Each kvp As KeyValuePair(Of String, Decimal) In currentFileValues
            vaProxy.SetDecimal(kvp.Key, kvp.Value)
        Next

    End Sub

    Private Shared Sub watcher_Changed(sender As Object, e As IO.FileSystemEventArgs) Handles watcher.Changed

        'This is the event fired every time file changes are committed to disk

        Using objFileStream = New IO.FileStream(watchedFile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)
            Using objStreamReader = New IO.StreamReader(objFileStream)
                Dim P3Dvalues As String()

                P3Dvalues = objStreamReader.ReadLine().Split("|"c)

                currentFileValues.Clear()
                currentFileValues.Add("VADaytime", Convert.ToDecimal(P3Dvalues(0)))
                currentFileValues.Add("VAstatus", Convert.ToDecimal(P3Dvalues(1)))
                currentFileValues.Add("VAtastat", Convert.ToDecimal(P3Dvalues(2)))
                currentFileValues.Add("VAcrstat", Convert.ToDecimal(P3Dvalues(3)))
            End Using
        End Using
    End Sub
End Class

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #11 on: December 15, 2016, 05:09:26 AM »
I really thank you for your help.

I have set the script as you detailled but I get this error when building :

Severity   Code   Description   Project   File   Line   Suppression State
Warning   CA2202   Object 'objFileStream' can be disposed more than once in method 'P3DBridge.watcher_Changed(Object, FileSystemEventArgs)'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 162
I don't have that warning on my VS 2015, but, at any rate, you can easily bypass it by applying an explicit 'try/catch' block on the outer object, instead of the double 'using' shortcut

See https://msdn.microsoft.com/en-us/library/ms182334.aspx
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #12 on: December 15, 2016, 09:06:05 AM »
I have cleared the error and managed to launch the pluggin from VA and get the value I want back. Only problem, the value is sent straight away back, the pluggin does not wait for the value to update before sending it back to VA.

Grrrr, I feel that I'm so close to the final solution but still am not able to find it on my own :-(

ralf44

  • Newbie
  • *
  • Posts: 41
Re: Problem with VB plugin reading a text fil
« Reply #13 on: December 15, 2016, 10:43:17 AM »
@Nico1854 as a quality of life side-note, since you are writing and accessing a text file every second I recommend you try the free version of RamDisk from Dataram.

Make a small Ramdisk and in the Load/Save tab of the configuration utility check the boxes for "Save Disk Image at Shutdown" and "Load Disk Image at Startup" so that it functions like a normal drive with persistence.

The free version has no nag screens and only limits you to a generous 4GB. If you play games on your computer you will find other great uses for this software! I am not affiliated or paid by Dataram, I just think that this is a useful app which is not very well-known.

http://memory.dataram.com/products-and-services/software/ramdisk

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #14 on: December 16, 2016, 10:07:43 AM »
I've got it to work.

Execute the pluggin from VA, then, the value I want is only returned once the text file is updated. Here is what I have changed (moving some script from VA_Init1 to VA_Invoke1 and adding some things :
Code: [Select]
          watcher.Path = IO.Path.GetDirectoryName(watchedFile)
            watcher.Filter = IO.Path.GetFileName(watchedFile)
            watcher.EnableRaisingEvents = True
            watcher.WaitForChanged(IO.WatcherChangeTypes.Changed)
            AddHandler watcher.Changed, AddressOf watcher_Changed

            Do
                Try
                    Dim fs As New IO.FileStream(watchedFile, IO.FileMode.Open, IO.FileAccess.ReadWrite, IO.FileShare.None, 100)
                    fs.ReadByte()
                    fs.Close()
                    Exit Do
                Catch
                    System.Threading.Thread.Sleep(100)
                End Try
            Loop
            'The currentFileValues dictionary contains all the latest values, you can simply return them
            For Each kvp As KeyValuePair(Of String, Decimal) In currentFileValues
                vaProxy.SetDecimal(kvp.Key, kvp.Value)
            Next

It's a great day for me and this is nearly all due to the kind help of Antaniserse who I thank again 1000 times.

Now that all the reading side is understood and works, I need to go the other way :

Say someting in VA, pass it to the plugin and then write it to a file. I know of to use the streamwriter but my first attemps failed.

In VA, passed the Decimal Variables by there name when executing the external plugin
In the plugin :
Code: [Select]
            objStreamWriter.WriteLine("depTA = ", vaProxy.depTA)
 
But the targeted file is not modified. So I guess that I'm doing it wrong with this last piece of script.
« Last Edit: December 17, 2016, 02:30:33 PM by Nico1854 »

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #15 on: December 17, 2016, 01:16:44 AM »
Got it.

To read VA variable and wright them in a text file :
Code: [Select]
Dim depTA As Decimal
        depTA = Convert.ToString(vaProxy.GetDecimal("depTA"))
        Dim desTA As Decimal
        desTA = Convert.ToString(vaProxy.GetDecimal("desTA"))
        Dim status As Decimal
        status = Convert.ToString(vaProxy.GetDecimal("status"))

        Dim objStreamWriter As System.IO.StreamWriter
        objStreamWriter = New System.IO.StreamWriter(".../P3DVars.lua")
        objStreamWriter.Write("depTA = ")
        objStreamWriter.WriteLine(depTA)
        objStreamWriter.Write("desTA = ")
        objStreamWriter.WriteLine(desTA)
        objStreamWriter.Write("status = ")
        objStreamWriter.WriteLine(status)

        objStreamWriter.Close()

If the VA Decimal variables are : depTA 8000, desTA 5000 and status 1000, the .lua file created will look like this :
depTA = 8000
desTA = 5000
status = 1000

I've written this into a lua file so that my main lua script can call this .lua file and run it as a script.
« Last Edit: December 17, 2016, 01:30:51 AM by Nico1854 »

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #16 on: December 20, 2016, 06:21:04 AM »
I would like the directory path to the files to read to be adapted to each User of the plugin.

Code: [Select]
    Private Const watchedFile As String = "...\P3DBridge.txt"
I was thinking of having a text file where each can wright the path to the directory containing the files to read.
I declared a variable set on the read of this text file and wanted to use it like this

Code: [Select]
    Private Const watchedFile As String = path "P3DBridge.txt"
But it seems that it is not possible to use a variale to build a constant.

What would be the best way to do so ?

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #17 on: December 21, 2016, 12:26:54 AM »
I would like the directory path to the files to read to be adapted to each User of the plugin.

Code: [Select]
    Private Const watchedFile As String = "...\P3DBridge.txt"
I was thinking of having a text file where each can wright the path to the directory containing the files to read.
I declared a variable set on the read of this text file and wanted to use it like this

Code: [Select]
    Private Const watchedFile As String = path "P3DBridge.txt"
But it seems that it is not possible to use a variale to build a constant.

What would be the best way to do so ?

Simply remove the 'Const' declaration and make watchedFile a normal variable, then you can build your path as you like: make it relative to the plugin folder, reading it from a config file or from a variable that your VA profile could set at startup, etc.
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #18 on: December 23, 2016, 07:18:21 AM »
As usual, I understand you and try. But after some time not finding the correct way, or not managing to correct the error message, I appreciate your help.

Here is what I tried, but always get an error in VA, "the path is not of a legal form"
(The txt in Path.txt file is C:\P3D\Modules)

Code: [Select]
Dim Filepath As String = My.Application.Info.DirectoryPath
        Filepath = Filepath & "\Apps\P3DBridge\Path.txt"
        Dim pathReader As System.IO.StreamReader
        pathReader = New System.IO.StreamReader(Filepath)
        Dim path As String
        path = pathReader.ReadLine
        pathReader.Close()
        Dim watchedFile As String = path + "\P3DBridge.txt"

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: Problem with VB plugin reading a text fil
« Reply #19 on: December 23, 2016, 07:28:44 AM »
I'm just reading diagonally here, but have you tried replacing "\" with "\\"? Backslash is an escape character, so you may need to double it up to get the actual character.

Nico1854

  • Guest
Re: Problem with VB plugin reading a text fil
« Reply #20 on: December 23, 2016, 07:31:57 AM »
Just gave it a try, but problem is the same

Also just tried replacing \ by /, but still the same

Antaniserse

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 87
    • My VA plugins
Re: Problem with VB plugin reading a text fil
« Reply #21 on: December 24, 2016, 05:32:25 AM »
Just gave it a try, but problem is the same

Also just tried replacing \ by /, but still the same

if you are unsure about how path strings are terminated (they have already a trailing '\' or they haven't or anything of that sort), just uso IO.Path.Combine, which will fix those for you

So, in your code
Code: [Select]
Dim Filepath As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "Apps\P3DBridge\Path.txt")
...
Dim watchedFile As String = IO.Path.Combine(path , "P3DBridge.txt")
"I am not perfect and neither was my career. In the end tennis is like life, messy."
Marat Safin