Hello Everyone:
I am new in programming and I am using vb2005.
This is what I have; I have created a project, where I allow the user to add a new record, when adding a new record they may have to included attachments, I have added an attachment button where I give the user a browse option to select any type of files and I am using the IO.Copy feature
So far this is working great; I have created a folder in my local drive where the file gets copied "C:\Program Files\Support Desk\Attachments\". When the user adds an attachment I have added a "Linklavel" where displays the File name;example "Picture.jpeg, textdoc.doc, testtxt.txt".HTML Code:System.IO.File.Copy(s, Destination & Path.GetFileName(s), True)
Here is where I am having problems; under the click event of the "Linklavel" I have added the following code:
In my project I have give the option to edit an added record, where the user can make notations and view the attachments if they have to.Code:'Declare those variables! Dim sFileName As String = "C:\program files\Support Desk\Attachments\" Dim myFileStream As New System.IO.FileStream(sFileName, _ FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None) 'Create the stream writer Dim myWriter As New System.IO.StreamWriter(myFileStream) 'Write in what is in the text box myWriter.WriteLine(LinkEditAttach1.Text) 'Flush before we close myWriter.Flush() 'Close everything myWriter.Close() myFileStream.Close() 'Clear the text LinkEditAttach1.Text = ""
I would like to when they click on one of the file names, to open the file for them to view it, or save it if they want to.
The code above is braking under the following line of code:
It tells me that path "C:\program files\Support Desk\Attachments\" doesn't exist.Code:Dim myFileStream As New System.IO.FileStream(sFileName, _ FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)
What am I doing wrong. is the code correct?
Thanks in advance.




Reply With Quote