easy app.config question

G

Guest

Hello All!

This seems pretty easy, but I'm missing something. In my app config file I
have
<add key="HL7File.Path" value="C:\Planes\STB" />

Then in my code I have below Windows Generated Code
Protected HL7File As String =
ConfigurationSettings.AppSettings("HL7File.Path")

Then when I need to call it.

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn.Click
Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "HL7File.Path"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
End Sub

I thought this would be pretty simple, what am I dong wrong? How can I call
that value back so I can use it?

TIA!

Rudy
 
M

Marc Scheuner

This seems pretty easy, but I'm missing something. In my app config file I
have
<add key="HL7File.Path" value="C:\Planes\STB" />

Then in my code I have below Windows Generated Code
Protected HL7File As String =
ConfigurationSettings.AppSettings("HL7File.Path")

Then when I need to call it.

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn.Click
Dim TimeStamp As String = Guid.NewGuid.GetHashCode
Dim TempFile As String = "HL7File.Path"
Dim ext As String = ".out"
Dim FileName As String = TempFile & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
End Sub

I thought this would be pretty simple, what am I dong wrong? How can I call
that value back so I can use it?

Well, you first read the value into your "HL7File" string, but then
you don't use that? Odd... :)

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn.Click
Dim TimeStamp As String = Guid.NewGuid.GetHashCode

// no need for that -
// you've already read the value into "HL7File" !
-- Dim TempFile As String = "HL7File.Path"

Dim ext As String = ".out"

// use that "HL7File" variable you've set up !
Dim FileName As String = HL7File & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
End Sub


HTH
Marc
 
G

Guest

Thanks Marc!

Marc Scheuner said:
Well, you first read the value into your "HL7File" string, but then
you don't use that? Odd... :)

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn.Click
Dim TimeStamp As String = Guid.NewGuid.GetHashCode

// no need for that -
// you've already read the value into "HL7File" !
-- Dim TempFile As String = "HL7File.Path"

Dim ext As String = ".out"

// use that "HL7File" variable you've set up !
Dim FileName As String = HL7File & TimeStamp & ext
Dim fs As New FileStream(FileName, FileMode.Create)
fs.Close()
File.Delete(FileName)
End Sub


HTH
Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top