How to read and write files in particular folders using vb.net or asp.net?

Posted by Gaddad under VB.NET on 10/20/2009 | Views : 3694 | Status : [Member] | Replies : 5
I want to create new file and write something and save it into some particular folder and open existing file in some particular folder and I have read/write access permission for that..

Please help how to do this....

Thanks..




Responses

Posted by: Vuyiswamb on: 10/20/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Gaddad

Use IO

To Create a File and Write on it

http://msdn.microsoft.com/en-us/library/d62kzs03.aspx


Reading and Writting look at this

http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Gaddad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tridev_2005 on: 10/20/2009 [Member] Starter

Up
0
Down
You Can use this code sample in vb.net

Imports System.IO



Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' We'll read all files from Images subfolder
Dim diFiles As DirectoryInfo = New DirectoryInfo(Server.MapPath("~/Images/"))
' Takes all .gif images,
' You can set some other filter or
' *.* for all files
lstFiles.DataSource = diFiles.GetFiles("*.gif")
' bind data to list box
lstFiles.DataBind()
End Sub
End Class


Gaddad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gaddad on: 10/20/2009 [Member] Starter

Up
0
Down
It is getting error - Name 'lstFiles' is not declared..

Pls..

Gaddad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 10/20/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
He is Binding the Files in a Listbox and the name of the listBox is "lstFiles" and you must add a Listbox to your page and name it "lstFiles".

Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Gaddad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 10/20/2009 [Member] Bronze

Up
0
Down
Hi Gaddad
plz follow below link u can get ur solution
http://santoshdotnetarena.blogspot.com/2009/09/write-birth-day-in-existing-in-xml.html

http://santoshdotnetarena.blogspot.com/2009/09/create-and-write-birthday-details-in.html

Regards
Santosh

Gaddad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response