Okay so I have created a script that should open and save text files according to the date which has been selected on a datetimepicker control.
In my Bin\Debug directory I have a text file named "30 December 2007.txt"
and here is my code:
vb Code:
Imports System.IO Public Class Form1 Dim SR As StreamReader Dim SW As StreamWriter Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged Dim theDatePicked As String = DateTimePicker1.Text & ".txt" SR = New StreamReader(theDatePicked) TextBox1.Text = SR.ReadToEnd End Sub Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click Dim theDatePicked As String = DateTimePicker1.Text & ".txt" SW = New StreamWriter(theDatePicked) SW.Write(TextBox1.Text) SW.Flush() End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim theDatePicked As String = DateTimePicker1.Text & ".txt" SR = New StreamReader(theDatePicked) TextBox1.Text = SR.ReadToEnd End Sub End Class
I keep getting this error message when I try to debug it.
An error occurred creating the form. See Exception.InnerException for details. The error is: Could not find file 'C:\Users\Matt's Computer\Documents\Visual Studio 2008\Projects\iDiary\iDiary\bin\Debug\.txt'.


Reply With Quote
