How to Change the default location of file --- VB.NET
-
I am making a VB.NET web application in VS.NET 2008. I am using streamwriter to write in the file. I am using filestream to create a new file Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write) using above line create the file in the default directory i.e (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) But i want to store my files in my defined directory say ("C:/HMSFiles/PPFiles/") how to replace the default directory with defined directory?? how to read the file from the defined directory? if i want to store these files on the server how to do this?? Here is the code:
Dim FilePath As String = ("C:/HMSfiles/PPFiles/")
Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)
Dim s As New StreamWriter(fs)
pretestcatch = pretestTA.Text
posttestcatch = posttestTA.Texts.WriteLine("PRE TEST PRECAUTIONS:")
s.NewLine = ""
s.Write(pretestcatch)s.WriteLine("POST TEST PRECAUTIONS:")
s.NewLine = ""
s.Write(posttestcatch)
s.Close() -
I am making a VB.NET web application in VS.NET 2008. I am using streamwriter to write in the file. I am using filestream to create a new file Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write) using above line create the file in the default directory i.e (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) But i want to store my files in my defined directory say ("C:/HMSFiles/PPFiles/") how to replace the default directory with defined directory?? how to read the file from the defined directory? if i want to store these files on the server how to do this?? Here is the code:
Dim FilePath As String = ("C:/HMSfiles/PPFiles/")
Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)
Dim s As New StreamWriter(fs)
pretestcatch = pretestTA.Text
posttestcatch = posttestTA.Texts.WriteLine("PRE TEST PRECAUTIONS:")
s.NewLine = ""
s.Write(pretestcatch)s.WriteLine("POST TEST PRECAUTIONS:")
s.NewLine = ""
s.Write(posttestcatch)
s.Close() -
Try
Dim fs As New FileStream(FilePath & "'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)
thanks Johnny. after posting i realized how to do it...but can u tell me how to save the file on server without using fileupload control in asp.net .....i want to store the content in textbox directly in file on server. and how to retrieve the file from the server. thanks
-
thanks Johnny. after posting i realized how to do it...but can u tell me how to save the file on server without using fileupload control in asp.net .....i want to store the content in textbox directly in file on server. and how to retrieve the file from the server. thanks