VB code to Open Text File - InfoPath Dev
in

InfoPath Dev

VB code to Open Text File

Last post 05-13-2009 09:55 AM by Ejuozaitis. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-13-2009 09:55 AM

    VB code to Open Text File

    Hello,  I am trying to write some VB code to open a text file (located on the SharePoint Server) when the form is opened as new, read the text (which would carry my autonumbers), place the text into a field on the form, write back to the file with a new number, and then close the file.  The problem that I am having is the last time that I wrote this routine, I got an error stating "SecurityException was unhandled by user", is there a work around to this issue?  I have provided the code below without true locations.  Any help would be appreciated.

    Dim fileContents As String, a As Integer, b As Integer

    fileContents = My.Computer.FileSystem.ReadAllText("\\weblocation\Database\Test1.txt")

    b = Convert.ToInt32(fileContents)

    a = b + 1

    My.Computer.FileSystem.WriteAllText("\\weblocation\Database\Test1.txt", a, True)

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.