|
-
Dec 13th, 2009, 04:22 PM
#1
Thread Starter
New Member
It refuses to write to a text file if the string used to be a path
Hi!
I've searched everywhere to find out why the heck my program is doing this, but couldn't find anything like it...?
I'm making a flash card program. Part of my program takes images corresponding to other data from a certain area, chosen by the user, and moves them to another folder, for later use. I want to store the path for the image next to the other data, storing the path as a string. When no image is chosen, the variable for the path is simply "no image".
For some reason, whenever the variable for the path contains an actual path, the program won't write it, but will when the variable is "no image".
This is the code where the user selects an image:
Code:
Private Sub btnImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImage.Click
imgBox.Width = 325
imgBox.Height = 350
opnImage.ShowDialog()
imagePath = opnImage.FileName
If imagePath <> "OpenFileDialog1" Then
n += 1
Dim fileExtension As String = Path.GetExtension(imagePath)
newName = n & fileExtension
newLocation = imgDirectory & newName
If File.Exists(newLocation) Then
File.Delete(newLocation)
End If
File.Copy(imagePath, newLocation)
imgBox.Image = Image.FromFile(newLocation)
ResizePicture()
End If
End Sub
This is the code for writing the information to the text file:
Code:
Sub WriteLine()
Dim courseFile As StreamWriter = File.AppendText(currentCourse & ".txt")
Dim newLine As String = Question & "@" & Answer & "@" & newLocation
courseFile.WriteLine(newLine)
End Sub
I have tried putting the path into a text box first, and then writing it from there, and it won't write. I've tried creating substrings from the path, and then putting them together, and it refuses. I am completely confused!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|